Skip to main content
added 361 characters in body
Source Link
Kusalananda
  • 356.5k
  • 42
  • 738
  • 1.1k
curl -Ls <git-script-path> | bash -s -- -p admin

This causes bash to read the shell commands from its standard input stream, which is connected to curl. The -p and admin are the two arguments that will be accessible as the positional parameters in the script. The -- is needed to signal the end of options for the bash executable.

Testing with a one-line script in script.sh which only does printf '"%s"\n' "$@" (outputs its command line arguments, quoted, on separate lines). We'll let cat script.sh be a stand-in for your curl command:

$ cat script.sh| bash -s -- -p admin
"-p"
"admin"

If your script requires interactivity, you can't read the script itself from standard input. Instead, provide the script via a filename:

$ bash <( curl -Ls <git-script-path> ) -p admin

This happens to be exactly what you have in your question. Note that this requires the current shell to understand process substitutions using <( ... ).

curl -Ls <git-script-path> | bash -s -- -p admin

This causes bash to read the shell commands from its standard input stream, which is connected to curl. The -p and admin are the two arguments that will be accessible as the positional parameters in the script. The -- is needed to signal the end of options for the bash executable.

Testing with a one-line script in script.sh which only does printf '"%s"\n' "$@" (outputs its command line arguments, quoted, on separate lines). We'll let cat script.sh be a stand-in for your curl command:

$ cat script.sh| bash -s -- -p admin
"-p"
"admin"
curl -Ls <git-script-path> | bash -s -- -p admin

This causes bash to read the shell commands from its standard input stream, which is connected to curl. The -p and admin are the two arguments that will be accessible as the positional parameters in the script. The -- is needed to signal the end of options for the bash executable.

Testing with a one-line script in script.sh which only does printf '"%s"\n' "$@" (outputs its command line arguments, quoted, on separate lines). We'll let cat script.sh be a stand-in for your curl command:

$ cat script.sh| bash -s -- -p admin
"-p"
"admin"

If your script requires interactivity, you can't read the script itself from standard input. Instead, provide the script via a filename:

$ bash <( curl -Ls <git-script-path> ) -p admin

This happens to be exactly what you have in your question. Note that this requires the current shell to understand process substitutions using <( ... ).

Source Link
Kusalananda
  • 356.5k
  • 42
  • 738
  • 1.1k

curl -Ls <git-script-path> | bash -s -- -p admin

This causes bash to read the shell commands from its standard input stream, which is connected to curl. The -p and admin are the two arguments that will be accessible as the positional parameters in the script. The -- is needed to signal the end of options for the bash executable.

Testing with a one-line script in script.sh which only does printf '"%s"\n' "$@" (outputs its command line arguments, quoted, on separate lines). We'll let cat script.sh be a stand-in for your curl command:

$ cat script.sh| bash -s -- -p admin
"-p"
"admin"