The harder way:
If you don't feed the in list option to select, it takes its options from the command line arguments.
It just so happens that set -- "Start Backup" Quit will set $1 to Start Backup and $2 to Quit
Therefore:
Code:
set -- "Start Backup" Quit
select opt; do
if [ "$opt" = "Start Backup" ]; then
echo "start backup"
exit
elif [ "$opt" = "Quit" ]; then
echo done
exit
fi
done
will get you an option with a space in it. Also remember that if you set PS3= a string, the string will follow your menu as a prompt.
Code:
PS3="Begin backup now: "
set -- "Start Backup" "No, Quit"
select opt; do
if [ "$opt" = "Start Backup" ]; then
echo "Starting backup"
exit
elif [ "$opt" = "No, Quit" ]; then
echo done
exit
fi
done
gets me:
Code:
1) Start Backup
2) No, Quit
Begin backup now: 1
Starting backup
Hope this helps!
Bookmarks