bash select loop
select - select from list.
select choice in `ls b*` quit
do
echo $choice
if [ "$choice" = quit ]
then
break
fi
done
Takes a list of strings and presents a numbered menu to user.
Takes numeric choice from user.
Places associated string in specified variable.
If invalid choice given, re-prompts user.
If user input is null, the list re-displayed.
Invalid choice will just generate new query prompt.
Requires break to exit out of loop.
Presented list is continuous, so avoid long lists, may scroll
off of screen.
set - set command line arguments.
set - normally used to list all set variables and functions.
set one "and to" tree for
for arg
do
echo $arg
done
Useful in functions
return - used trigger return from functions and to set a 1 byte
return code of the function.
return is only valid inside a function.
exit - used in trigger exit from script and to set a 1 byte return
code on exit. If used on command line, it will exit the current shell.
exit will exit script even if inside a function.