zsh-users
 help / color / mirror / code / Atom feed
From: DervishD <raul@pleyades.net>
To: Zsh Users <zsh-users@sunsite.dk>
Subject: Double input and 'exec' builtin
Date: Thu, 17 Jun 2004 15:54:39 +0200	[thread overview]
Message-ID: <20040617135439.GA22462@DervishD> (raw)

    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/


                 reply	other threads:[~2004-06-17 13:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040617135439.GA22462@DervishD \
    --to=raul@pleyades.net \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).