Skip to content

Instantly share code, notes, and snippets.

@oakaigh
Last active October 11, 2018 10:53
Show Gist options
  • Save oakaigh/321c8c60d453c5d69fe852371d3c1c74 to your computer and use it in GitHub Desktop.
Save oakaigh/321c8c60d453c5d69fe852371d3c1c74 to your computer and use it in GitHub Desktop.
wickJSON () {
key=$1
re="\"($key)\": \"([^\"]*)\""
while read -r l; do
if [[ $l =~ $re ]]; then
name="${BASH_REMATCH[1]}"
value="${BASH_REMATCH[2]}"
echo "$name=$value"
else
return -1
fi
done
}
prompt="Pick an option:"
options=("A" "B" "C")
PS3="$prompt "
select opt in "${options[@]}" "Quit"; do
case "$REPLY" in
1 ) echo "You picked $opt which is option $REPLY";;
2 ) echo "You picked $opt which is option $REPLY";;
3 ) echo "You picked $opt which is option $REPLY";;
$(( ${#options[@]}+1 )) ) echo "Goodbye!"; break;;
*) echo "Invalid option. Try another one.";continue;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment