From d5f86effa1837f5f409427885e18ae0450d421f4 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 29 Aug 2020 14:28:53 +0200 Subject: [PATCH] ls: Explicitly enforce that the user specifies a snapshot ID The help messages suggested that the `ls` command work without explicitly passing a snapshot ID. However, this was never the case: without a snapshot ID the command just failed with the error `Ignoring "", it is not a snapshot id`. Fixes #2299 --- cmd/restic/cmd_ls.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/restic/cmd_ls.go b/cmd/restic/cmd_ls.go index dec46a375..76c133e00 100644 --- a/cmd/restic/cmd_ls.go +++ b/cmd/restic/cmd_ls.go @@ -16,7 +16,7 @@ import ( ) var cmdLs = &cobra.Command{ - Use: "ls [flags] [snapshotID] [dir...]", + Use: "ls [flags] snapshotID [dir...]", Short: "List files in a snapshot", Long: ` The "ls" command lists files and directories in a snapshot. @@ -89,8 +89,8 @@ type lsNode struct { } func runLs(opts LsOptions, gopts GlobalOptions, args []string) error { - if len(args) == 0 && len(opts.Hosts) == 0 && len(opts.Tags) == 0 && len(opts.Paths) == 0 { - return errors.Fatal("Invalid arguments, either give one or more snapshot IDs or set filters.") + if len(args) == 0 { + return errors.Fatal("no snapshot ID specified") } // extract any specific directories to walk