From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Mon, 5 Oct 2009 17:20:48 +1100 From: Sam Watkins To: 9fans@9fans.net Message-ID: <20091005062048.GD22078@nipl.net> References: <20091004071748.GA16895@nipl.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.13 (2006-08-11) Subject: Re: [9fans] mishandling empty lists - let's fix it Topicbox-Message-UUID: 7e3fa3b6-ead5-11e9-9d60-3106f5b1d025 > 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