mount: fix exit code on cancellation

This commit is contained in:
Michael Eischer 2024-04-05 22:23:08 +02:00
parent 6f2a4dea21
commit 910927670f
2 changed files with 6 additions and 1 deletions

View File

@ -190,7 +190,7 @@ func runMount(ctx context.Context, opts MountOptions, gopts GlobalOptions, args
Warnf("unable to umount (maybe already umounted or still in use?): %v\n", err) Warnf("unable to umount (maybe already umounted or still in use?): %v\n", err)
} }
return nil return ErrOK
case <-done: case <-done:
// clean shutdown, nothing to do // clean shutdown, nothing to do
} }

View File

@ -25,6 +25,8 @@ func init() {
_, _ = maxprocs.Set() _, _ = maxprocs.Set()
} }
var ErrOK = errors.New("ok")
// cmdRoot is the base command when no other command has been specified. // cmdRoot is the base command when no other command has been specified.
var cmdRoot = &cobra.Command{ var cmdRoot = &cobra.Command{
Use: "restic", Use: "restic",
@ -125,6 +127,9 @@ func main() {
if err == nil { if err == nil {
err = ctx.Err() err = ctx.Err()
} else if err == ErrOK {
// ErrOK overwrites context cancelation errors
err = nil
} }
switch { switch {