9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] mishandling empty lists - let's fix it
@ 2009-10-03 16:03 Sam Watkins
  2009-10-03 17:01 ` Rob Pike
                   ` (2 more replies)
  0 siblings, 3 replies; 56+ messages in thread
From: Sam Watkins @ 2009-10-03 16:03 UTC (permalink / raw)
  To: 9fans

hi,

I wanted to have a whinge about one fault I find in unix: commands such as cat,
grep etc. do not handle an empty argument list correctly.  For example,

  cat

should output nothing and exit - concatenating 0 files.  Instead it copies
stdin to stdout, which is inconsistent.  This problem still exists in plan 9.

Copying stdin should be coded as:

  cat -

Such syntax would provide useful extra capability:

  find -type d | cat lib/emptydirs - | mail 9fans@9fans.net

Although this bug is not annoying for command-line work, consider a script that
processes all .c files to be found using cat or grep:

  find -name '*.c' | xargs cat | cc -     # this clever cc can handle it :)

This program works fine until there are no .c files to be found, in that case
it hangs, waiting for one on stdin!  This is a hazard to shell scripters, and a
potential source of security holes.  It's worse than cat -v.

Another example:

  8c && echo 1

should compile 0 files to give an empty object file, and echo 1.

Is there any chance we could fix these things in plan 9/inferno?
I feel that freedom from past mistakes is a key principle of plan 9.

If people support this change, I would be keen to work on it.

thanks!

Sam


(I noticed the "pike" language has a similar bug, `+(1,2,3) -> 6
but `+() -> error!  `+() should be 0 and `*() should be 1, of course.)
I don't think such bugs exist in Lisp :)



^ permalink raw reply	[flat|nested] 56+ messages in thread
[parent not found: <<646955677faa922172207300b93ff6ea@hamnavoe.com>]
[parent not found: <<20091005055423.GA14691@nipl.net>]
[parent not found: <<200910060740.aa94573@salmon.maths.tcd.ie>]
[parent not found: <<200910070930.aa64725@salmon.maths.tcd.ie>]
[parent not found: <<200910071414.aa02318@salmon.maths.tcd.ie>]

end of thread, other threads:[~2009-10-07 14:02 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-03 16:03 [9fans] mishandling empty lists - let's fix it 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-06 16:35               ` [9fans] *Suspect* " W B Hacker
2009-10-04 10:59         ` [9fans] " 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
     [not found] <<646955677faa922172207300b93ff6ea@hamnavoe.com>
2009-10-04 18:39 ` erik quanstrom
     [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
2009-10-05 21:35       ` Russ Cox
     [not found] <<200910060740.aa94573@salmon.maths.tcd.ie>
2009-10-06 12:59 ` erik quanstrom
     [not found] <<200910070930.aa64725@salmon.maths.tcd.ie>
2009-10-07 12:14 ` erik quanstrom
2009-10-07 13:14   ` John Stalker
     [not found] <<200910071414.aa02318@salmon.maths.tcd.ie>
2009-10-07 13:36 ` erik quanstrom
2009-10-07 14:02   ` W B Hacker

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).