From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: set -F kills read -t
Date: Thu, 20 Mar 2014 08:49:27 -0700 [thread overview]
Message-ID: <532B0E07.7050106@eastlink.ca> (raw)
In-Reply-To: <140319212148.ZM5101@torch.brasslantern.com>
[-- Attachment #1: Type: text/plain, Size: 2633 bytes --]
On 03/19/2014 09:21 PM, Bart Schaefer wrote:
> On Mar 19, 6:46pm, Ray Andrews wrote:
> }
> } Ok Bart, how would you write it? The above is a bridgehead in as much
> } as it accepts input from either end
>
> Command line arguments are a fundamentally different kind of "input".
Yeah, I know. I'm speaking in a sloppy way because I'm focusing in on
the 'grep'
situation where the command can be fed from either end. But of course it
seems
that that is particular to grep, not zsh syntax itself, so you're right
to suspect my
understanding.
>
> I'm still not sure I understand exactly what you want to do,
This! :
function y ()
{
if [ ! -t 0 ]; then cat
else echo '(nothing in the pipe)'; fi
if [ $# -gt 0 ]; then print -r -- "$*"
else echo '(nothing in the args)'; fi
}
Except that we've come in a circle. Try calling it from this alias:
alias y='set -F; _y'
function _y ()
{
if [ ! -t 0 ]; then cat
else echo '(nothing in the pipe)'; fi
if [ $# -gt 0 ]; then print -r -- "$*"
else echo '(nothing in the args)'; fi
}
.... back to 'set -F' killing the pipe :-(
$ echo "My love is" | _y "as a fever"
My love is
as a fever
$ echo "My love is" | y "as a fever"
(nothing in the pipe)
as a fever
> If that's how you meant for it to work, I can't improve on what you
> have, except for some cosmetics (for example, you should not test
> [ -n "$1" ] because it's possible for $1 to be empty and $2 to have
> something in it).
That's a rude shock but I just tested it, and right you are.
Anyway '[ $# -gt 0 ]' is obviously robust, so I like it.
> (or pretty much anything else in your chain of pipes) that it will just
> sit there forever waiting for something? It's reading the terminal,
> because that's what the shell tells it is the standard input. That's
> what all those programs that "just work" doing: an unconditional,
> blocking-forever, read from somewhere, stdin by default.
Yes! And that's how God meant it to be ;-)
> As soon as you throw in the bit about not waiting on the terminal when
> there is no pipe on the left, you have to start worrying about a lot
> of the stuff that you didn't worry about before.
Misericordia
Bart, I'm taking too much of your time. The list functions at a higher
level than my
novice problems. I'm dabbling in sacred mysteries that are above me. Let
me get
back to Peter's book and throw myself at this stuff when I know a bit
more Coptic. C
is meant to be understandable and predictable, the shells are meant to
be like playing
Dungeons and Dragons.
next prev parent reply other threads:[~2014-03-20 15:49 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
2014-03-20 4:21 ` Bart Schaefer
2014-03-20 15:49 ` Ray Andrews [this message]
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=532B0E07.7050106@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).