Here's an installer I'm writing with all the irrelevant bits removed:
#!/bin/bash
echo "In the prompt below, type 'install' or 'remove' (without the quotes)"
echo "If you type neither, this script will terminate."
read -p "Action to perform: " OPERATION
if [ "$OPERATION" == "install" ]
then
echo "Installing..."
echo "Install successful!"
elif [ "$OPERATION" == "remove" ]
then
echo "Removing..."
echo "Remove successful!"
else
echo "Aborting with no actions"
fi
This script works exactly as you'd expect. When I type install
, the install section executes, when I type remove
the remove section executes and finally when I type random characters, it aborts.
But the same script with the #!/bin/bash
replaced with either #!/bin/sh
or left empty (my regular shell is ZSH), it errors out:
In the prompt below, type 'install' or 'remove' (without the quotes)
If you type neither, this script will terminate.
Action to perform: sdfsdfdsf
./test.sh: 7: [: sdfsdfdsf: unexpected operator
./test.sh: 11: [: sdfsdfdsf: unexpected operator
Aborting with no actions
For some context, I'm on Ubuntu Studio 18.04 with zsh --version
printing zsh 5.4.2 (x86_64-ubuntu-linux-gnu)
.
Can someone help me understand why this is happening?