0

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?

Hayk
  • 123
  • 5
  • 2
    `bash -c nginx -g daemon off` is running just `nginx`, with `-g daemon off` being arguments to *bash*, not `nginx`. – muru Jul 20 '22 at 05:31
  • ^^ this. Try `bash -c 'nginx -g daemon off'` to get the same error. – pLumo Jul 20 '22 at 05:32
  • @muru but I guess eventually `-g daemon off` should be the argument of `nginx` so why when using `bash -c` it doesn't give this error `nginx: invalid option: "off"`? – Hayk Jul 20 '22 at 06:52
  • @Hayk no, that's not how it works. Read the answers in the duplicate. – muru Jul 20 '22 at 07:51

0 Answers0