adzdavies
adzdavies

Reputation: 1555

Why use -Lo- with curl when piping to bash?

In the janus project, they use curl to download and pipe a bootstrap script into bash. https://github.com/carlhuda/janus

It looks like this:

$ curl -Lo- https://bit.ly/janus-bootstrap | bash

Why would one want to use the args -Lo-?

-o is supposed to be for output, but wouldn't that happen anyway (i.e. to stdout)?

Upvotes: 10

Views: 15473

Answers (2)

Zombo
Zombo

Reputation: 1

The -o is redundant, they produce the exact same output:

$ curl --silent example.com | sha256sum
3587cb776ce0e4e8237f215800b7dffba0f25865cb84550e87ea8bbac838c423 *-

$ curl --silent --output - example.com | sha256sum
3587cb776ce0e4e8237f215800b7dffba0f25865cb84550e87ea8bbac838c423 *-

They have used that syntax since that line was first introduced in 2011. You might ask Wael Nasreddine (@kalbasit on GitHub) why he did it. He is still active on that repo.

Upvotes: 7

Nir Alfasi
Nir Alfasi

Reputation: 53535

It's all in the man pages:

-L in case the page has moved (3xx response) curl will redirect the request to the new address

-o output to a file instead of stdout (usually the screen). In your case the o flag is redundant since the output is piped to bash (for execution) - not to a file.

Upvotes: 12

Related Questions