On Mon, Jun 26, 2023 at 03:36:58PM -0300, Hugo Napoli wrote: > #!/bin/bash > > clear > > echo "" > read -p "Ingrese un número entero de hasta 2 cifras > : " min > read -p "Ingrese otro número entero de hasta 2 cifras, mayor que el > anterior : " max > > if [[ ${#min} -gt 2 ]] || [[ ${#max} -gt 2 ]];then > clear > echo "" && echo "Deben ser números de hasta 2 cifras..." > read -p "Pulse ENTER para continuar..." > bash "$0" > fi
You really don't want to use bash "$0" here. That runs a new instance of your script, but it leaves the old one suspended in memory, waiting for the new instance to finish. Once the new instance finishes, the original instance continues. So, depending on how many times the user gives bad input, you could have dozens or hundreds of instances of your script in memory simultaneously, and once the user gives valid input, they'll all run, one after the other, in reverse order, using the bad inputs. If you want to loop until the user gives valid input, use while or until. #!/bin/bash while true; do clear echo read -p "Ingrese un número entero de hasta 2 cifras : " min read -p "Ingrese otro número entero de hasta 2 cifras, mayor que el anterior : " max if ((${#min} > 2 || ${#max} > 2)); then echo "Deben ser números de hasta 2 cifras..." read -p "Pulse ENTER para continuar..." elif ((min >= max)); then echo "The second number must be larger..." read -p "Pulse ENTER para continuar..." else break fi done [...] (I'll let you translate the second error message. My Spanish is poor.)