7

I was wondering what is the purpose of piping the downloaded file by curl into sudo -E bash - in the following shell:

curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -

8

It's a short way of executing a script without having to save the file and then execute it. When you save the file and then execute it, a number of things can go wrong:

  • User didn't type the filename correctly
  • User didn't use the correct shell (maybe ran sh foo.sh instead of bash foo.sh)
  • User tried to execute the file instead of setting bash on it (./foo.sh), and forgot to set execute permissions
  • User forgot to use sudo

By providing a single command line to execute, the developers can decrease the number of places where things can go wrong due to luser error.

Personally, I despise piping curl to bash. It's not safe.

6

This command would download file and attempt to execute it with root privileges.

  • 2
    Thank you, but what is the pupose of -E option and - at the end of command ? – Mr.Y Mar 11 '17 at 7:12
  • 4
    @Youssef -E preserves environment variables (say variables for proxy settings) and - tells bash to read commands from standard input, i.e., the pipe. – muru Mar 11 '17 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.