3 ms·
Part of the reason is that your connection could be interrupted … and then now what? Hope you like sifting through the script’s entirety and manually checking
by gnubison 4y ago
Part of the reason is that your connection could be interrupted … and then now what? Hope you like sifting through the script’s entirety and manually checking how much it’s done so far.
- chii 4y agoi'd imagine the download would have to finish first, before the piping into bash finishes and then bash interprets the finished script. I find it hard to believe you could interpret a partial script on the fly as more comes in via stdin.
- scbrg 4y agoNo, that's exactly how it works. Why would you write such a thing when you're clearly just guessing? A shell script is interpreted one line at the time. Very simple proof: $ while true; do printf 'date\n' && sleep 5; done | sh Mon 16 May 2022 07:19:21 AM CEST Mon 16 May 2022 07:19:26 AM CEST Mon 16 May 2022 07:19:31 AM CEST In either case, if the network connection is interrupted, the download is finished. How would sh know it's not the whole script as the author intended it? Remember that in a pipeline the receiving end only sees the pipe, and won't know about the exit status of the process upstream (which may for all we know be zero anyway).