#!/bin/bash
PS3="Select an install package: "
items=("Essentials - VLC"
"Graphics Suite - Inkscape, GIMP, Blender"
"Streaming Suite - OBS, Openshot, Blender")
select opt in "${items[@]}" "Cancel - Install Manually"
do
case $opt in
1) echo "== Installing Essentials ==";
sudo apt install vlc -y; wait; break;;
2) echo "== Installing Graphics Suite ==";
sudo apt install vlc inkscape gimp blender -y; wait; break;;
3) echo "== Installing Streaming Suite ==";
sudo apt install vlc obs openshot blender -y; wait; break;;
$((${#items[@]}+1)))
echo "Remember, you can manually install with";
echo " 'sudo apt install [app name]'";
echo " 'sudo flatpak install [app name]'";
echo "or through the 'Software Manager'";
sleep 8; break;;
*) echo "Invalid option - please select a number from 1 to $((${#items[@]}+1))";
esac
done
clear
I'm experimenting with an item select command. When I open the script as an executable and it opens a terminal window (top example), the script runs as expected. But when I open the Terminal and run the script with a sh command (bottom example), I get an "(" unexpected syntax error on line 42 and the script breaks.
What's going on here?
# Line 42 lands on the options tab.
options=("Essentials - VLC"\
"Graphics Suite - Inkscape, GIMP, Blender"\
"Streaming Suite - OBS, Openshot, Blender")
I also tried it on a single line (without the backslashes) but got the same error result when I tried to run it from the Terminal with sh.
EDIT: I tried running it with bash and it ran without breaking, but now it gives me the else condition: *) echo "Invalid option... no matter which option I pick.
declare -p opt >&2to log what valueopthas before you enter yourcase.