The command is: nginx -g daemon off
My current shell:
root@aws:~# echo $0
bash
root@aws:~# nginx -g daemon off
nginx: invalid option: "off"
root@aws:~# bash -c nginx -g daemon off
root@aws:~#
Note:
If I use double quotes across daemon off
so that it will represent one word it will work: nginx -g "daemon off;"
The question arises: If my shell is bash, why then is there an execution difference between not specifying bash -c
and explicitly specifying it?
bash -c nginx -g daemon off
is running justnginx
, with-g daemon off
being arguments to bash, notnginx
. – muru Jul 20 '22 at 05:31bash -c 'nginx -g daemon off'
to get the same error. – pLumo Jul 20 '22 at 05:32-g daemon off
should be the argument ofnginx
so why when usingbash -c
it doesn't give this errornginx: invalid option: "off"
? – Hayk Jul 20 '22 at 06:52