[tz] tzselect.ksh fails under ksh, works under bash

Alan Barrett apb at cequrux.com
Sun Jul 20 11:01:53 UTC 2014

If BASH_VERSION is not set, then tzselect.ksh performs a test in
which it attmepts to use the select command, to see whether the
select command is available:

84:    (eval 'set --; select x; do break; done; exit') 2>/dev/null

In the case that the shell is not bash, but the select command is 
available, then the select command reads a line of input.  This is 
confusing for users, who don't even see a prompt.

The attached patch fixes this by redirecting input from /dev/null.  I
also quoted some variables on general principles.

--apb (Alan Barrett)
-------------- next part --------------
diff --git i/tzselect.ksh w/tzselect.ksh
index e799a1a665..4268ce07df 100644
--- i/tzselect.ksh
+++ w/tzselect.ksh
@@ -77,11 +77,11 @@ Report bugs to $REPORT_BUGS_TO."
 # Exit on EOF or I/O error.  Use the shell's 'select' builtin if available,
 # falling back on a less-nice but portable substitute otherwise.
-  case $BASH_VERSION in
+  case "$BASH_VERSION" in
   ?*) : ;;
     # '; exit' should be redundant, but Dash doesn't properly fail without it.
-    (eval 'set --; select x; do break; done; exit') 2>/dev/null
+    (eval 'set --; select x; do break; done; exit') 2>/dev/null </dev/null
   # Do this inside 'eval', as otherwise the shell might exit when parsing it
@@ -98,7 +98,7 @@ then
     # Work around a bug in bash 1.14.7 and earlier, where $PS3 is sent to stdout.
-    case $BASH_VERSION in
+    case "$BASH_VERSION" in
       case `echo 1 | (select x in x; do break; done) 2>/dev/null` in
       ?*) PS3=

More information about the tz mailing list