0

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?

Jwan622
  • 11,015
  • 21
  • 88
  • 181
  • It isn't called anything "in bash". As far as `bash` is concerned, it is just a parameter passed to the `python` command. Python interprets as meaning "read the script from standard input". (Read `man python`) – Stephen C Oct 19 '21 at 14:27
  • Not to be confused with a Unicode hyphen or dash character (see https://jkorpela.fi/dashes.html) ... which will thoroughly confuse `python` ... and you. – Stephen C Oct 19 '21 at 14:35

1 Answers1

2

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.

Heinzi
  • 167,459
  • 57
  • 363
  • 519