What is the meaning of the switches and parameters of this command?
exec su -s /bin/sh -c 'exec "$0" "$@"' root -- /opt/nsq/bin/nsqdSpecifically the -- part and what exec "$0" "$@" is supposed to do.
I know $0 sets a loop for the script to keep running.
You can ignore the /opt/nsq/bin/nsqd part. This is the app I'm running.
1 Answer
execThe command it runs, su, replaces the shell without creating a new process.
sudo -s /bin/sh -c The substitute user runs the specified shell, /bin/sh and executes the following command.
exec "$0" "$@"Run command $0 , the name of the script, (your first variable, i.e., /opt/nsq/bin/nsqd )
"$@"with all the arguments, using the appropriate quoting
--The double hyphens delimit the option list. Everything following, even if they begin with a hypen, are considered to be operands. For example, sort -- -r reads from the file named -r instead of trying to use '-r' as an option.