1

Bash Manual says about bash -c <some-command>:

Read and execute commands from the first non-option argument after processing the options, then exit. Any remaining arguments are assigned to the positional parameters, starting with $0.

What do the following mean:

  • "the first non-option argument after processing the options"
  • "Any remaining arguments are assigned to the positional parameters, starting with $0"

In the second one, are the positional parameters for bash or for some-command?

Tim
  • 101,790

1 Answers1

3

"the first non-option argument after processing the options"

This is talking about options to your invocation of bash. -c, for example, is an option you're applying to bash in your example that would not be sent to any command you're invoking.

"Any remaining arguments are assigned to the positional parameters, starting with $0"

What this means, is that if you execute bash -c /path/to/script arg1 arg2, the specified script will be executed with /path/to/script, arg1, and arg2 being assigned to the positional parameters $0, $1, and $2 respectively, just as though you had run the command in an interactive bash session.

DopeGhoti
  • 76,081