From 3dec664a19b10ea9885d29f5a4b768d81a1c259b Mon Sep 17 00:00:00 2001 From: albertony <12441419+albertony@users.noreply.github.com> Date: Sat, 27 Jan 2024 20:44:12 +0100 Subject: [PATCH] bisync: change exit code from 2 to 7 for critically aborted run --- cmd/bisync/cmd.go | 3 ++- cmd/bisync/operations.go | 2 +- docs/content/bisync.md | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/bisync/cmd.go b/cmd/bisync/cmd.go index 22a600923..c8b2136c4 100644 --- a/cmd/bisync/cmd.go +++ b/cmd/bisync/cmd.go @@ -20,6 +20,7 @@ import ( "github.com/rclone/rclone/fs/config" "github.com/rclone/rclone/fs/config/flags" "github.com/rclone/rclone/fs/filter" + "github.com/rclone/rclone/fs/fserrors" "github.com/rclone/rclone/fs/hash" "github.com/spf13/cobra" @@ -193,7 +194,7 @@ var commandDefinition = &cobra.Command{ cmd.Run(false, true, command, func() error { err := Bisync(ctx, fs1, fs2, &opt) if err == ErrBisyncAborted { - os.Exit(2) + return fserrors.FatalError(err) } return err }) diff --git a/cmd/bisync/operations.go b/cmd/bisync/operations.go index b457645fa..987a94e66 100644 --- a/cmd/bisync/operations.go +++ b/cmd/bisync/operations.go @@ -23,7 +23,7 @@ import ( "github.com/rclone/rclone/lib/terminal" ) -// ErrBisyncAborted signals that bisync is aborted and forces exit code 2 +// ErrBisyncAborted signals that bisync is aborted and forces non-zero exit code var ErrBisyncAborted = errors.New("bisync aborted") // bisyncRun keeps bisync runtime state diff --git a/docs/content/bisync.md b/docs/content/bisync.md index 8f0bf4883..94a51fd9e 100644 --- a/docs/content/bisync.md +++ b/docs/content/bisync.md @@ -968,12 +968,15 @@ that while concurrent bisync runs are allowed, _be very cautious_ that there is no overlap in the trees being synched between concurrent runs, lest there be replicated files, deleted files and general mayhem. -### Return codes +### Exit codes `rclone bisync` returns the following codes to calling program: - `0` on a successful run, - `1` for a non-critical failing run (a rerun may be successful), -- `2` for a critically aborted run (requires a `--resync` to recover). +- `2` on syntax or usage error, +- `7` for a critically aborted run (requires a `--resync` to recover). + +See also the section about [exit codes](/docs/#exit-code) in main docs. ### Graceful Shutdown