Created
February 3, 2017 16:19
Revisions
-
TheBox193 created this gist
Feb 3, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ # Description: # A simple prompt for bash that supports a default value. # ${ask} QUESTION DEFAULT # # Example: # BRANCH=$(ask "Which Branch?" "master") function ask(){ local QUESTION=$1 local DEFAULT=$2 local ANSWER read -p "${QUESTION} [${DEFAULT}] " ANSWER [ -z "${ANSWER}" ] && ANSWER=$DEFAULT echo $ANSWER }