I have a script
install.sh essentially looks like this:
#!/bin/bash if [[ ! -f "/usr/bin/jq" ]]; then apt-get update && apt-get install -y jq fi echo $(date) >> install.log
If I put it on a server, and run it like this:
curl -s0 https://myserver.com/install.sh | bash
after the crazy
apt-get output, it won't run the last
echo line, instead it prints the line
echo $(date) >> test.log as output. While if I save the
install.sh on the disk, and run
./install.sh, it runs as expected. the echo line is executed and the
install.log is appended.
To further reproduce this issue, I run it locally like this:
cat install.sh | bash
it also has the same problem.
apt-get remove jq manually before each test. If
jq is installed, then both work as expected. So why it's different to run it from the download vs. run it from local file?
I recorded a short video to demonstrate this problem: https://www.youtube.com/watch?v=lYvGXI7AibA