zsh-users
 help / color / mirror / code / Atom feed
* Double input and 'exec' builtin
@ 2004-06-17 13:54 DervishD
  0 siblings, 0 replies; only message in thread
From: DervishD @ 2004-06-17 13:54 UTC (permalink / raw)
  To: Zsh Users

    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/


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-06-17 13:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-17 13:54 Double input and 'exec' builtin DervishD

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).