9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Sam Watkins <sam@nipl.net>
To: 9fans@9fans.net
Subject: Re: [9fans] mishandling empty lists - let's fix it
Date: Mon,  5 Oct 2009 17:20:48 +1100	[thread overview]
Message-ID: <20091005062048.GD22078@nipl.net> (raw)
In-Reply-To: <e11719893918245eca4b3a165b16987d@proxima.alt.za>

> you're retaining the inconsistency, but candy-coating it.

No, I'm offering a simple syntax using which one can avoid the inconsistency.
I'm retaining the option to have inconsistent behaviour, for backward
compatibility, and because some people seem to like it for command-line use.

  cat *      # still ok, will break if no files match, or a file called -v etc
  cat -- *   # more reliable  (so long as * returns empty if it fails to match)

The new syntax comes for free with `--', which is the standard syntax used by
almost all programs that take options and also process one or more files named
on the command line.  `--' is needed so that these programs can cope with
filenames starting with a dash like `-README-' for example, and not confuse
them with options.  All serious scripters should be using this `--' already,
especially if they are doing sysadmin work, otherwise their scripts may break
or go on a rampage deleting stuff when some user makes a file called `-rf'.

This fix (to support zero-length file lists when using `--') would not only
keep compatibility, it would also fix a whole lot of buggy scripts that are
using `--' but not checking for the empty list.

> I doubt anyone should invest the time and effort to implement this

I've added support for this feature into my get_options function, which I use
in my own programs.  It took me about 1 minute to do that.  I expect a similar
amount of time would be needed to fix each major tool having the problem.
There might be 10 or 20 such tools that are commonly used in plan 9.
So it would be less than a couple hours work.

> cat -
> cat /fd/0
> cat

There's no longer any need to implement support for `cat -' and similar to
avoid the problem of mishandling empty file lists, although it might be nice.

I'm sick of this topic like everyone else must be so that's all from me.


Sam



  reply	other threads:[~2009-10-05  6:20 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=20091005062048.GD22078@nipl.net \
    --to=sam@nipl.net \
    --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).