Skip to content

Instantly share code, notes, and snippets.

@fpinzn
Created May 15, 2014 12:16
Show Gist options
  • Save fpinzn/e8bed0d0d48428618445 to your computer and use it in GitHub Desktop.
Save fpinzn/e8bed0d0d48428618445 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Displays the received arguments as options and returns the option selected
# Set the prompt for the select command
PS3="Type a number or 'q' to quit: "
# Show a menu and ask for input. If the user entered a valid choice return it.
select option in "$@"; do
if [ -n "$option" ]; then
echo ${option}
fi
break
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment