I'm new to BASH and I have to write a BASH file.
I have this if statement
if [[ ${disp} != ?(-)+([0-9]) ]] || [[ $disp -ne 1 ]] || [[ $disp -ne 0 ]]
then
echo -e "Parametro disponibilidade tem que ser '0' ou '1'!"
echo -e "disponivel - 1, indisponivel - 0"
exit 1
fi
The second and the third conditions don't work. However if I delete the last condition
if [[ ${disp} != ?(-)+([0-9]) ]] || [[ $disp -ne 1 ]]
then
echo -e "Parametro disponibilidade tem que ser '0' ou '1'!"
echo -e "disponivel - 1, indisponivel - 0"
exit 1
fi
The last condition works!! Can't someone explain me why this happens and how would you do it?
It should check if the user input is an integer and that integer must be 0 or 1, else bash exits
Thanks for your help