[Lunar-commits] CVS: theedge/var/lib/lunar/functions messages.lunar, 1.19, 1.20

Auke Kok sofar at lunar-linux.org
Tue Mar 15 11:38:46 UTC 2005


Update of /var/cvs/lunar/theedge/var/lib/lunar/functions
In directory espresso.foo-projects.org:/home/sofar/active/theedge/var/lib/lunar/functions

Modified Files:
	messages.lunar 
Log Message:
New query() routine: bad input now causes a repeated question, and the double newline is gone.


Index: messages.lunar
===================================================================
RCS file: /var/cvs/lunar/theedge/var/lib/lunar/functions/messages.lunar,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- messages.lunar	10 Dec 2004 10:46:33 -0000	1.19
+++ messages.lunar	15 Mar 2005 11:38:44 -0000	1.20
@@ -108,36 +108,33 @@
 
 query() {
   debug_msg "query ($@)"
-  #  2 arguments
-  #  query  "what do you want?  "  DEFAULT
-
-  if  [  -z  "$SILENT"  ];  then
-
-    # message  "Press y for yes, n for no."
-    if  [  -n  "$MODULE"  ];  then
-      echo  -e  -n  "${MODULE_COLOR}${MODULE}${DEFAULT_COLOR}:  "
-      echo  -e  -n  "${QUERY_COLOR}$1 [$2] ${DEFAULT_COLOR}"
-    else
-      echo  -e  -n  "${QUERY_COLOR}$1 [$2] ${DEFAULT_COLOR}"
-    fi
-
-    read   -t  $PROMPT_DELAY  -n  1  RESPONSE
-    echo
-
-    RESPONSE=${RESPONSE:=$2}
-    case  $RESPONSE  in
-      y|Y)  true  ;;
-        *)  false ;;
-    esac
+  # 2 arguments
+  # query "what do you want?  "  DEFAULT
 
+  if [ -z "$SILENT" ]; then
+    while [ -z "$RESPONSE" ]; do
+      if [ -n "$MODULE" ]; then
+        echo -e -n "${MODULE_COLOR}${MODULE}${DEFAULT_COLOR}: "
+      fi
+      echo -e -n "${QUERY_COLOR}$1 [$2] ${DEFAULT_COLOR}"
+      read -t $PROMPT_DELAY -n 1 RESPONSE
+      if [ -z "$RESPONSE" ]; then
+        RESPONSE=${RESPONSE:=$2}
+      else
+        echo
+      fi
+      case $RESPONSE in
+        y|Y)  true  ;;
+        n|N)  false ;;
+          *)  unset RESPONSE ;;
+      esac
+    done
   else
-
-    echo  $2
-    case  $2  in
-        y|Y)  true    ;;
-          *)  false   ;;
+    case $2 in
+      y|Y)  true    ;;
+      n|N)  false   ;;
+        *)  message "Error: bad input in query()" ; exit 1  ;;
     esac
-
   fi
 }
 



More information about the Lunar-commits mailing list