I'm new in this business and I've got a problem...
In my while-loop I compare an user input with a variable. The problem is if the user input is a space or a special charakter I cant compare it. (In the If Else too but I think the solution for while and if else is the same) Here is the code so you can see it.
var1="therealpass"
counter=0
tries=3
read -sp 'Please enter the password! (3 tries left): ' pass_var
while (( $pass_var != $var1 || $counter < 2 ))
do
if [ $pass_var == $var1 ]
then
echo "That was the real password! Good job!"
break
else
counter=$[counter + 1]
tries=$[tries - 1]
if [ $tries == 1 ]
then
echo
echo "$tries try left. Please try it again!"
read -sp 'Password: ' pass_var
echo
else
echo
echo "$tries tries left. Please try it again!"
read -sp 'Passwort: ' pass_var
fi
fi
done