Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Menu/UNIX-Shell/menu.sh
Normal file
19
Task/Menu/UNIX-Shell/menu.sh
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# choose 'choice 1' 'choice 2' ...
|
||||
# Prints menu to standard error. Prompts with PS3.
|
||||
# Reads REPLY from standard input. Sets CHOICE.
|
||||
choose() {
|
||||
CHOICE= # Default CHOICE is empty string.
|
||||
[[ $# -gt 0 ]] || return # Return if "$@" is empty.
|
||||
select CHOICE; do # Select from "$@".
|
||||
if [[ -n $CHOICE ]]; then
|
||||
break
|
||||
else
|
||||
echo Invalid choice.
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
PS3='Which is from the three pigs: '
|
||||
choose 'fee fie' 'huff and puff' 'mirror mirror' 'tick tock'
|
||||
[[ -n $CHOICE ]] && echo You chose: $CHOICE
|
||||
[[ -z $CHOICE ]] && echo No input.
|
||||
Loading…
Add table
Add a link
Reference in a new issue