File tree Expand file tree Collapse file tree 1 file changed +26
-7
lines changed Expand file tree Collapse file tree 1 file changed +26
-7
lines changed Original file line number Diff line number Diff line change @@ -141,23 +141,42 @@ function pick_one_virtual_host_from_file() {
141141 local EXCEPT=$2
142142
143143 local HOST_STRING
144- local HOSTS
144+ local HOSTS=()
145145 local HOST
146+ local HOST_OPTIONS=()
146147
147148 HOST_STRING=$( sed -nr ' s/.*VIRTUAL_HOST=(.*)/\1/p' " $FILE " )
148149
149150 IFS=" ," read -ra HOSTS <<< " $HOST_STRING"
150151
151152 for HOST_ENTRY in " ${HOSTS[@]} " ; do
152- if [ " $HOST_ENTRY " != " $EXCEPT " ]; then
153- HOST=$HOST_ENTRY
154- break ;
155- fi
153+ if [ " $HOST_ENTRY " != " $EXCEPT " ]; then
154+ HOST_OPTIONS+=(" $HOST_ENTRY " )
155+ fi
156156 done
157157
158- if [ -z " $HOST " ]; then
159- output_error " No VIRTUAL_HOST found in $FILE ."
158+ if [ " ${ # HOST_OPTIONS[@]} " -eq " 0 " ]; then
159+ output_error " No VIRTUAL_HOST overrides found in $FILE ."
160160 exit 1
161+ elif [ " ${# HOST_OPTIONS[@]} " -gt " 1" ]; then
162+ PS3=" Select a Proxy URL (or quit to exit): "
163+ while [ -z " $HOST " ]; do
164+ select opt in " ${HOST_OPTIONS[@]} " ; do
165+ if [ -z " $opt " ]; then
166+ if [ " $REPLY " == " quit" ]; then
167+ output_info " Exiting..."
168+ exit 1
169+ fi
170+ >&2 output_error " Invalid selection: $REPLY . Please enter the number of the option you wish to select."
171+ continue
172+ fi
173+
174+ HOST=$opt
175+ break
176+ done
177+ done
178+ else
179+ HOST=${HOST_OPTIONS[0]}
161180 fi
162181
163182 echo " $HOST "
You can’t perform that action at this time.
0 commit comments