[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bash enhancement to "select"]

From: bs
Subject: [Bash enhancement to "select"]
Date: Fri, 20 Oct 2000 22:54:54 +0200

Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-I./include -I./lib -I/usr/local/include -g -O2
uname output: Linux firestar 2.2.17 #3 Tue Sep 26 15:44:50 SAST 2000 i686 
Machine Type: i686-pc-linux-gnu

Bash Version: 2.04
Patch Level: 0
Release Status: release

        [The 'select' function does not have a timeout. And the default
                behaviour of the [return] key is painfull in the sense
                that it just loops. The 'select' function is beautiful
                for selecting on data who's size and quantity you don't
                know - however if you have a default value - and want
                to choose *that* on a simple [Return] - you can't -
                you have to retype a selection. Painful. The 'READ'
                function now has some beautiful args - eg Timeout
                (-t xx) and Length (-n xx). It would be most ideal if
                'select' could use them too - after all 'select' does
                use the 'builtin-read' !!!! - and one more arg to change
                the behavior in which 'select' deals with just a [return]
                being pressed]

                select fname in /tmp/*
                  echo you picked $fname \($REPLY\)

     To fix the pain of "Return" - 

      execute_cmd.c - line 1825
      repl_string = get_string_value ("REPLY");
      if (*repl_string == 0)
        /* MJE * continue; */
        return "";

      ie - change the 'continue' into a 'return "null string"'.  I'm not
      sure what 'Posix' states - but to get the old effect put the
      whole 'select' into a 'while' loop and 'continue' if '$REPLY'
      has a 'null' value.
      To add a timeout in the 'select', we created a new shell variable
      'READTMOUT'... and fooled around with some appropiate values.

      builtins/read.def - line 143

  /* *MJE* IF READTMOUT is unset, we use the default of "-1". */
  var = find_variable("READTMOUT");
  if (var && var->value) tmout = atoi(var->value);
  if (tmout < 1 || tmout > 10000000) /* ie - a stupid value */
        tmout = -1;             /* no timeout */

     Yup - Ugly - but the shell scripting works beautifully...
        I know they are not proper context diffs - but only two small changes 

        All changes done by Mark J Elkins. <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]