My if statement always evaluates to false within the my switch statement. I tried using boolean variables and now just numerics and I get the same result. The if statement isn't working.
#!/bin/bash
hidden=1
while true; do
read -sn 1 input
case $input in
q )
;;
n )
;;
h ) if ! [ $hidden ]; then # hide video
echo "hidden (false): $hidden"
hidden=1
else # show video
echo "hidden (true): $hidden"
hidden=0
fi
;;
'' ) ;;
\? );;
esac
done
exit 0
If I run it and press "h" a few times I get..
hidden (true): 1
hidden (true): 0
hidden (true): 0
hidden (true): 0
Why does my if statement always evaluate to false?
Aucun commentaire:
Enregistrer un commentaire