Link to home
Start Free TrialLog in
Avatar of beer9
beer9Flag for India

asked on

what is the role of "bash -s"?

I see following line to install chefdk

curl -L https://chef.io/chef/install.sh | sudo bash -s -- -P chefdk

Open in new window


I want to understand that does "bash -s -- -P chefdk" does and how does '-P' gets supplied as option to 'install.sh' and not to 'bash' ?
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
-s makes bash read commands (the "install.sh" code as downloaded by "curl") from stdin, and accept positional parameters nonetheless.

"--" lets bash treat everything which follows as positional parameters instead of  options.

bash will set the variables "$1" and "$2" of the "install.sh" code to "-P" and to "chefdk", respectively.
Hi woolmilkporc,

> "bash will set the variables "$1" and "$2" of the "install.sh" code to "-P" or to "chefdk", respectively."

Does this mean that after running that whole one-liner, the 1st & 2nd "words" (for lack of a better word) of the output of the curl command will be accessible via $1 & $2?

Also, any ideas why "sudo" is being used here?  Does it imply the user doesn't even have access to run bash without sudo?
Does this mean that after running that whole one-liner, the 1st & 2nd "words" (for lack of a better word) of the output of the curl command will be accessible via $1 & $2?
No
Also, any ideas why "sudo" is being used here?
Perhaps so that the commands in https://chef.io/chef/install.sh can be run as root
Does it imply the user doesn't even have access to run bash without sudo?
No
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks ozo for a concise answer, as usual.

And thanks even more for a well explained answer, woolmilkpork.