Let's assume I have a file named confirmation.sh
with the following content:
#!/bin/bash
echo -n "Are you sure [Y/n]? "
read line
case "$line" in
n|N) echo "smth"
;;
y|Y) echo "smth"
;;
esac
and I want to run this script in the following way:
cat confirmation.sh | sh
I see Are you sure [Y/n]?
and the script is interrupted. What's the problem?
/bin/bash
in the bang line, yet you use a.sh
extension and try to pipe the script tosh
. Not a problem since the code you have is compatible with both, but worth pointing out.