From: Jason Catena <jason.catena@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] mishandling empty lists - let's fix it
Date: Tue, 6 Oct 2009 15:10:53 -0500 [thread overview]
Message-ID: <d50d7d460910061310o23ff8826made0a8f0eccd4290@mail.gmail.com> (raw)
In-Reply-To: <200910062027.ac05515@salmon.maths.tcd.ie>
On Tue, Oct 6, 2009 at 14:27, John Stalker <stalker@maths.tcd.ie> wrote:
>> just write a single combinator that when applied to a command
>> makes it behave in the "no non-flag arguments == dont run" way.
>> Then its just:
>>
>> l0 cat $args
>> l0 chmod +x $args
>
>> Tim Newsham
>
> There is also a problem with identifying non-flag arguments.
For the original post's purpose ("commands such as cat, grep etc. do
not handle an empty argument list correctly") we might not have to go
this far. If these new semantics are meant to process command line
arguments, then they should not be used with the l0 combinator to
process pipe input, which means they won't be called without some
attempt to supply them with arguments after options. Common cases
where the attempt might provide no arguments would be shell variables
or backticked commands, which are both code that gets further
processed. We can use this to delay the processing into the
combinator, and not execute the utility command if we have nothing to
do.
So, it should be sufficient to either (1) quote the argument-providing
code in the command line, to delay evaluating it until immediately
before the utility command in the combinator, and if non-nil apply its
output to the utility command; or (2) add some null argument like
/dev/null, depending on the command, in the combinator after any other
arguments, to make it quietly do nothing if the argument-providing
code evaluates to nil in the calling script.
Seems to me we have three different command sets now: one with the
current, traditional semantics which mix argument and pipe input, and
handle missing input inconsistently; a set (listed by John) which
handle no command-line arguments consistently. generally doing
nothing; and a set (listed by Ron) which handle standard input
consistently. Of the three, Ron's set seems most interesting to me:
(1) if your tools can handle their arguments on standard input, they
ought to cleanly handle the null case too, (2) pipe is a cleaner
notation for passing output along than backtick within backtick within
backtick, and (3) pipes commonly pass multiple lines, not just
separated fields.
> John Stalker
Jason Catena
next prev parent reply other threads:[~2009-10-06 20:10 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <<20091005055423.GA14691@nipl.net>
2009-10-05 13:30 ` erik quanstrom
2009-10-05 16:13 ` Russ Cox
2009-10-05 19:24 ` Sam Watkins
2009-10-05 19:31 ` erik quanstrom
2009-10-05 21:04 ` John Stalker
2009-10-05 22:13 ` Jason Catena
2009-10-06 10:10 ` lucio
2009-10-06 2:22 ` ron minnich
2009-10-06 4:37 ` erik quanstrom
2009-10-06 4:50 ` ron minnich
2009-10-06 6:40 ` John Stalker
2009-10-06 17:45 ` Brian L. Stuart
2009-10-06 18:00 ` John Stalker
2009-10-06 18:27 ` ron minnich
2009-10-07 8:30 ` John Stalker
2009-10-07 11:05 ` roger peppe
2009-10-06 8:40 ` matt
2009-10-06 16:50 ` John Stalker
2009-10-06 17:15 ` Jason Catena
2009-10-06 17:50 ` Tim Newsham
2009-10-06 19:27 ` John Stalker
2009-10-06 20:10 ` Jason Catena [this message]
2009-10-05 21:35 ` Russ Cox
[not found] <<200910071414.aa02318@salmon.maths.tcd.ie>
2009-10-07 13:36 ` erik quanstrom
2009-10-07 14:02 ` W B Hacker
[not found] <<200910070930.aa64725@salmon.maths.tcd.ie>
2009-10-07 12:14 ` erik quanstrom
2009-10-07 13:14 ` John Stalker
[not found] <<200910060740.aa94573@salmon.maths.tcd.ie>
2009-10-06 12:59 ` erik quanstrom
[not found] <<646955677faa922172207300b93ff6ea@hamnavoe.com>
2009-10-04 18:39 ` erik quanstrom
2009-10-03 16:03 Sam Watkins
2009-10-03 17:01 ` Rob Pike
2009-10-03 18:31 ` Sam Watkins
2009-10-03 18:56 ` Rob Pike
2009-10-03 19:05 ` blstuart
2009-10-03 19:18 ` hiro
2009-10-03 20:31 ` Steve Simon
2009-10-05 16:08 ` John Stalker
2009-10-05 16:24 ` erik quanstrom
2009-10-05 17:20 ` John Stalker
2009-10-05 19:09 ` roger peppe
2009-10-03 18:46 ` Bakul Shah
2009-10-03 19:11 ` Sam Watkins
2009-10-04 4:12 ` lucio
2009-10-04 7:17 ` Sam Watkins
2009-10-04 9:18 ` lucio
2009-10-05 6:20 ` Sam Watkins
2009-10-05 6:53 ` Federico G. Benavento
2009-10-04 10:46 ` Richard Miller
2009-10-06 6:59 ` Uriel
2009-10-06 12:01 ` Jacob Todd
2009-10-04 10:59 ` sqweek
2009-10-05 5:54 ` Sam Watkins
2009-10-05 11:23 ` matt
2009-10-04 10:18 ` Charles Forsyth
2009-10-04 10:26 ` lucio
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=d50d7d460910061310o23ff8826made0a8f0eccd4290@mail.gmail.com \
--to=jason.catena@gmail.com \
--cc=9fans@9fans.net \
/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.
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).