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 offis running justnginx, with-g daemon offbeing 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 offshould be the argument ofnginxso why when usingbash -cit doesn't give this errornginx: invalid option: "off"? – Hayk Jul 20 '22 at 06:52