From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: set -F kills read -t
Date: Wed, 19 Mar 2014 18:46:36 -0700 [thread overview]
Message-ID: <532A487C.4040906@eastlink.ca> (raw)
In-Reply-To: <140319152144.ZM4783@torch.brasslantern.com>
On 03/19/2014 03:21 PM, Bart Schaefer wrote:
> I'm still curious what put you on to "-t" in the first place.
I was just Googling for advice on how to get a function to accept piped
input and 'read -t'
came up several times. Monkey see, monkey do.
> Another thing you may be missing here is that "read" consumes ONE LINE
> of text: A string ending in "\n" (or end of file). If you do not use
> "-t", then it waits as long as it must in order to gobble up one line.
> But it won't wait for a second line.
Yes, I know that. But it's a place to start.
> (Of course you can tell it that something other than a "\n" should be
> used as a the line ending, in which case it may very well swallow
> everything up to end-of-file on the pipe, but that requires even more
> fooling around and -t has you quite well enough confused already.)
>
> } function y ()
> } {
> } pipeinput='(nothing in the pipe)'
> } terminalinput='(nothing from the terminal)'
> } if [ ! -t 0 ]; then read pipeinput; fi
> } if [ -n "$1" ]; then terminalinput="$@"; fi
> } echo "$pipeinput $terminalinput"
> } }
>
> It's a little odd to call $@ the "terminal input" -- you can have stdin
> come from a tty device the same as from any other file. All that the
> above has said is that you never want to read from a tty, but you're
> willing to read exactly one line from anywhere else. Consider:
>
> $ y 'I met a man with seven wives' <<<'As I was going to St Ives'
>
> As long as your clams are happy, though ...
Now don't go confusin' me again ;-)
Hmmm ... no, you're right, it should be able to accept any volume of
input as a matter of principal.
Ok Bart, how would you write it? The above is a bridgehead in as much
as it accepts input from
either end, but how could it be improved? I tried 'cat' with no luck.
I've already done some chains of
pipes (using binaries) up to maybe half a dozen steps, and you just
don't have to worry about time-outs,
or single lines or anything at all, it just works, even on Tuesday.
next prev parent reply other threads:[~2014-03-20 2:16 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-02 14:26 implementing a control for completing filenames with a defined list of tokens Eric Smith
2013-12-02 15:58 ` Bart Schaefer
2014-03-16 14:13 ` Eric Smith
2014-03-16 19:27 ` Bart Schaefer
2014-03-16 20:13 ` Bart Schaefer
2014-03-18 3:10 ` set -F kills read -t Ray Andrews
2014-03-18 6:50 ` Bart Schaefer
2014-03-18 16:22 ` Ray Andrews
2014-03-18 16:47 ` Peter Stephenson
2014-03-18 17:45 ` Bart Schaefer
2014-03-18 22:08 ` Ray Andrews
2014-03-18 23:12 ` Jan Larres
2014-03-19 4:06 ` Ray Andrews
2014-03-19 5:30 ` Jan Larres
2014-03-19 15:23 ` Ray Andrews
2014-03-19 20:00 ` Bart Schaefer
2014-03-20 1:47 ` Ray Andrews
2014-03-19 1:17 ` Bart Schaefer
2014-03-19 5:00 ` Ray Andrews
2014-03-19 6:37 ` Bart Schaefer
2014-03-19 17:08 ` Ray Andrews
2014-03-19 17:22 ` Roman Neuhauser
2014-03-19 22:21 ` Bart Schaefer
2014-03-20 1:46 ` Ray Andrews [this message]
2014-03-20 4:21 ` Bart Schaefer
2014-03-20 15:49 ` Ray Andrews
2014-03-20 16:08 ` Bart Schaefer
2014-03-20 21:27 ` Ray Andrews
2014-03-19 10:00 ` Roman Neuhauser
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=532A487C.4040906@eastlink.ca \
--to=rayandrews@eastlink.ca \
--cc=zsh-users@zsh.org \
/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).