I wrote Bash script and now I want to convert it to Ash. One headache is this function:
do_adduser() {
setaddprompt
_arr_add=("Add manually" "Add via TXT" "return to main menu" "exit program")
select add_action in "${_arr_add[@]}"
do
case "$REPLY" in
1) do_manual_add ;;
2) do_txt_add ;;
3) return ;;
4) exit 0 ;;
*) badchoice ;;
esac
setaddprompt
done
}
This function prints out the options and allows selection. First the ash error handler had me change the brackets as such
_arr_add={"Add manually" "Add via TXT" "return to main menu" "exit program"}
select add_action in "$(_arr_add[@])"
Which I think will be better. But now it is complaining about a missing "}" bracket.
line 72: syntax error: unexpected "do" (expecting "}")
When I get rid of the do statement, the error goes away. I tried adding a while before hand. It didn't make a difference so it's presently uncommented, and the code is bellow.
do_adduser() {
setaddprompt
# _arr_add={"Add manually" "Add via TXT" "return to main menu" "exit program"}
#select add_action in "$(_arr_add[@])"
echo "Select Option:
1) Add manually
2) Add via TXT
3) Return to Main Menu
4) Exit Program
"
# while[true];
do;
case "$REPLY" in
1) do_manual_add ;;
2) do_txt_add ;;
3) return ;;
4) exit 0 ;;
*) badchoice ;;
esac
setaddprompt
done
}
Does anybody know how I can change this to an 'ash' script successfully?
---------- Post updated at 06:17 PM ---------- Previous update was at 06:14 PM ----------
To summarize, I can't get the 'do' statement to work.