--stdin-from-command interpret arguments as command to execute and store its stdout
restic backup .... --stdin-from-command ls # works
restic backup .... --stdin-from-command ls -l # fails
restic backup .... --stdin-from-command "ls -l" # fails
restic backup .... --stdin-from-command ls --stdin-from-command "-l" # fails
restic backup .... --stdin-from-command ls --stdin-from-command /root # works!
The help text says arguments, so I would think more than one argument to --stdin-from-command is possible, but it does not seem so. Is it possible at all to pass arguments with leading “-” to the command, can you give a working example for bash?
Proposal for help text, adjusting to existing help texts (–password-command, --option)
--stdin-from-command command execute command and store its stdout (can be specified several times for passing arguments)
And maybe a working example for something like “ls -l” in the documentation?
Your shell Restic is interpreting parts of the command you supply as being part of the --stdin-from-command option rather than arguments to the restic command.
You need to use the -- notation to tell the shell where the options of the command end and the arguments start, so add -- after --stdin-from-command.
EDIT: It is not the shell, which I initially wrote, but the flag package in Go, and thereby restic, which interprets the options/flags/arguments and the --, as pointed out by @bernd.
Just to be precise, in this case the shell has nothing to do with interpreting the parts after --stdin-from-command. It’s restic itself that interprets the command line parts. The -- notation tells restic to stop grabbing additional command line parts as restic instructions.