How do I pass command-line arguments to script executed from stdin

92 Views Asked by At

These work fine:

/bin/dash xyz.sh arg1
curl | /bin/dash -

Use case:

curl | sh - arg1

Ubuntu executes this as:

curl | /bin/dash - arg1

this fails with: sh: 0: Can't open arg1

How do I pass arg1 to curl | /bin/dash?

1

There are 1 best solutions below

0
Aliaksei Budavei On

Here's a lark, to pass e.g. the localhost localhost arguments
to curl as requested:

echo curl --head '"$@"' | sh -s localhost localhost