"<< (command-here)" shell idiom leading to "unexpected redirection"

This command works just fine:

$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

However, I don’t understand how exactly it stableis passed as a parameter to the shell script loaded by curl. This is the reason why I cannot achieve the same functionality from my own shell script - it gives me ./foo.sh: 2: Syntax error: redirection unexpected:

$ cat foo.sh 
#!/bin/sh
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

So the questions are: how exactly stabledoes this parameter get into the script, why does this command have two redirects, and how do I change this command to work inside my script?

+5
source share
1 answer

:

stable, script /bin/sh, bash. <() POSIX, bash /bin/sh ( ).

shebang #!/bin/bash.

< <():

, - <() , , ; Linux /dev/fd/##. < <(command), stdin... .

, , :

read foo < <(echo "bar")
echo "$foo"

:

echo "bar" | read foo
echo "$foo"

, , . , , , .

bash -s stable:

bash -s , script stdin. script [email protected] ($1, $2 ..), stable $1, script, stdin.

+12

All Articles