I have this:
bash <(
curl_url='https://raw.githubusercontent.com/oresoftware/run-tsc-if/master/run.sh'
curl -H 'Cache-Control: no-cache' --silent "$curl_url"
)
the bash script at that url, takes one argument $1...is there a way to pass an argument using this style of execution or would I need to use an environment variable instead?
I supposed this could work?
bash "first arg" <(
curl_url='https://raw.githubusercontent.com/oresoftware/run-tsc-if/master/run.sh'
curl -H 'Cache-Control: no-cache' --silent "$curl_url"
)
but that's just a guess, and seems wrong..
ok from my testing this does seem right:
bash <(
my_url='https://raw.githubusercontent.com/oresoftware/run-tsc-if/master/run.sh'
curl -H 'Cache-Control: no-cache' --silent "$my_url"
) "first arg" # add the argument here
if someone could verify that'd be good..it seems like this verifies it:
bash <(echo 'echo "first: $1"') 'blaq'
that will echo:
first: blaq
set -xin your shell, and see what a process substitution like<(...)turn into, and why the last version works.bashread the downloaded script from its stdin (bash reading a script from stdin in bash is horrible, because it will do aread(2)system call for each byte, and may have other inintended consequences). Simplybash <(curl ...) av1 av2 av3 ...would work. (Of course, running scripts off githup is madness, but that's not a technical problem ;-)).