I have this small code snippet in a shellscript to set a password:
if [[ -z "${PASS+x}" ]]; then
read -p "enter pass or use default [test1234]" PASS
if [[ -z "$PASS" ]]; then
PASS="test1234"
fi
fi
if [ $EUID != 0 ]; then
sudo "$0" "$@"
exit $?
fi
When I run the script the read command is executed twice. This isn't supposed to happen. Can anybody help me with finding the error.
complete script: github (corrected already)
readcommand shouldn't be executed twice, because you call it one time. And there's no loop it your code.echo "enter ...." read -s PASS, but its still the same. I have no idea where the error is.-xoption and paste the output. Ifreadis being invoked twice, it will show up.