Home > OS >  What does this "python -" do?
What does this "python -" do?

Time:10-19

I see this command:

curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -

What does this to? What is the "-" called in bash?

CodePudding user response:

This has nothing to do with bash. - has a very specific meaning when passed to the python binary:

-

Read commands from standard input (sys.stdin). [...]

Since, in your example,

  • curl outputs the downloaded file to stdout and
  • the shell pipe | passes curl's output to python's stdin,

python will execute the commands contained in the file downloaded by curl.


Note that this is a convention commonly found in various command-line utilities: Providing a single hyphen in place of a file name causes the command to read input from stdin instead of a file.

  •  Tags:  
  • bash
  • Related