Im not experienced with bash, but i seem to run into some random gotchas all the time when working on my scripts...
INPUT=""
input() {
read -n 1 -p ":" INPUT
}
console() {
if [[ $INPUT == "1" ]]; then
hideMenu
menu1
elif [[ $INPUT == "2" ]]; then
hideMenu
menu2
elif [[ $INPUT == "3" ]]; then
hideMenu
menu3
elif [[ $INPUT == "menu" ]]; then
showMenu
elif [[ $INPUT == "q" ]]; then
quit
fi
}
This code works. it will read the input and then act according.
Then i have seemingly same thing in different file
J_INPUT=""
j_input() {
read -n 1 -p ":" J_INPUT
}
console() {
if [ $J_INPUT = "l"]; then
CURR_PAGE=$((CURR_PAGE + 1))
elif [ $J_INPUT = "j"]; then
CURR_PAGE=$((CURR_PAGE - 1))
elif [ $J_INPUT = "asd"]; then
CURR_PAGE=$((CURR_PAGE + 1))
fi
}
This however will not run for some reason. Also if i now try to use [[ ]] bash will throw an syntax error ?
What is wrong here? why cant i use the same syntax? what does [[ ]] valuate ?
Thanks.
Aucun commentaire:
Enregistrer un commentaire