Browse code

kamctl: kamdbctl.base - replaced get_answer() with a portable version

- contributed by Sergey Safarov, GH #2019

Daniel-Constantin Mierla authored on 16/09/2019 08:12:47
Showing 1 changed files
... ...
@@ -205,16 +205,11 @@ merr() {
205 205
 #
206 206
 get_answer ()
207 207
 {
208
-    value=$1
209
-    question=$2
210
-    if [ "${value}" = "ask" ]; then
211
-        echo -n "$question"
212
-        read ANSWER
213
-    else
214
-        ANSWER=${value}
215
-    fi
216
-    ANSWER=${ANSWER:0:1}
217
-    ANSWER=${ANSWER/Y/y}
218
-    ANSWER=${ANSWER/N/n}
208
+	value=$1
209
+	question=$2
210
+	if [ "${value}" = "ask" ]; then
211
+		echo -n "$question"
212
+		read value
213
+	fi
214
+	ANSWER=$(echo ${value} | grep -o -e '[YyNn]' | sed -e 's/Y/y/' -e 's/N/n/')
219 215
 }
220
-