Posted Jun 12, 2012 16:34 UTC (Tue) by nybble41 (subscriber, #55106)
[Link]
> Could you explain me again what '|sh |sh' does please?
It takes the output of some command and runs it as a script (piping it through the shell), and then takes the output of that script and runs it through the shell again. Two layers of shell indirection.
Alan Cox celebrates the queen
Posted Jun 12, 2012 19:11 UTC (Tue) by hummassa (subscriber, #307)
[Link]
> Could you explain me again what '|sh |sh' does please?
simple example:
h@off:~$ echo echo echo oi |sh |sh
oi
(the outermost echo echoes "echo echo oi", which when ran thru sh echoes "echo oi", which when ran thru sh echoes "oi")...
h@off:~$ echo echo echo oi
echo echo oi
h@off:~$ echo echo echo oi |sh
echo oi
h@off:~$ echo echo echo oi |sh |sh
oi
Alan Cox celebrates the queen
Posted Jun 14, 2012 2:28 UTC (Thu) by jzbiciak (✭ supporter ✭, #5246)
[Link]
I came here to write almost the identical example, only with "echo echo echo bah | sh | sh". Also, I thought about making a joke about grumpy librarians writing shell scripts, but thought better of it. ;-)
And then there's the (briefly) amusing result you get when you apply such an incantation to a shell quine. You can |sh as many times as you wish!