2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-22 10:58:55 +00:00

Align Stdin and StdinCommand in conditionals

In order to run with --stdin-from-command we need to short-circuit some functions similar to how it is handled for the --stdin flag. The only difference here is that --stdin-from-command actually expects that len(args) should be greater 0 whereas --stdin does not expect any args at all.

Signed-off-by: Sebastian Hoß <seb@xn--ho-hia.de>
This commit is contained in:
Sebastian Hoß 2023-03-16 07:45:07 +01:00 committed by Michael Eischer
parent a8657bde68
commit 333fe1c3cf

View File

@ -289,7 +289,7 @@ func (opts BackupOptions) Check(gopts GlobalOptions, args []string) error {
} }
} }
if opts.Stdin { if opts.Stdin || opts.StdinCommand {
if len(opts.FilesFrom) > 0 { if len(opts.FilesFrom) > 0 {
return errors.Fatal("--stdin and --files-from cannot be used together") return errors.Fatal("--stdin and --files-from cannot be used together")
} }
@ -300,7 +300,7 @@ func (opts BackupOptions) Check(gopts GlobalOptions, args []string) error {
return errors.Fatal("--stdin and --files-from-raw cannot be used together") return errors.Fatal("--stdin and --files-from-raw cannot be used together")
} }
if len(args) > 0 { if len(args) > 0 && opts.StdinCommand == false {
return errors.Fatal("--stdin was specified and files/dirs were listed as arguments") return errors.Fatal("--stdin was specified and files/dirs were listed as arguments")
} }
} }
@ -368,7 +368,7 @@ func collectRejectFuncs(opts BackupOptions, targets []string) (fs []RejectFunc,
// collectTargets returns a list of target files/dirs from several sources. // collectTargets returns a list of target files/dirs from several sources.
func collectTargets(opts BackupOptions, args []string) (targets []string, err error) { func collectTargets(opts BackupOptions, args []string) (targets []string, err error) {
if opts.Stdin { if opts.Stdin || opts.StdinCommand {
return nil, nil return nil, nil
} }