Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Double input and 'exec' builtin



    Hi all :)

    I have a script that processes standard input and after that
prints some data and waits for user input, something like:

    #!/bin/zsh

    emulate -L zsh

    select ITEM in `filter`
    do
        print $ITEM
        break;
    done

    # End of script

    Obviously this doesn't work, because 'select' needs standard
input (or the line editor) to read the user selection, but 'filter'
processes standard input as well!. Well, I've modified it like this:

    #!/bin/zsh

    emulate -L zsh

    set `filter`

    select ITEM
    do
        print $ITEM
        break;
    done

    # End of script

    thus separating the filter processing from the selection, but it
doesn't work either. I need to do the following in order to make it
work:

    #!/bin/zsh

    emulate -L zsh

    set `filter`

    exec < /dev/tty
    select ITEM
    do
        print $ITEM
        break;
    done

    # End of script

    Is there any cleaner way of doing all this? I want to solve two
problems. First, the 'set' part. I don't really want to use the
positional parameters for this, although they won't be used in this
script. I've thought about using a shell parameter instead of 'set'
and positional parameters, and using ${(f)that_variable} for
generating the list for 'select'. The other problem is separating the
part of the script that processes standard input from the select,
without making two scripts and without that 'exec'.

    Any idea? Thanks a lot for your help :)

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/



Messages sorted by: Reverse Date, Date, Thread, Author