From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 6 Oct 2009 06:24:28 +1100 From: Sam Watkins To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Message-ID: <20091005192428.GA24445@nipl.net> References: 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: 7f371326-ead5-11e9-9d60-3106f5b1d025 John Stalker: > For what it's worth, I agree that it's a problem. hooray! thanks :) > Does it need fixing? Implementing it properly would break most shell scripts > I've written. Well, I have a fix that should not break any real scripts, I repeat it below. Russ Cox: > to the original poster: there's definitely a logical consistency to your > original proposal. others have pointed out specific flaws, but the > fundamental issue is that it's just not the same system anymore. Thanks. I've already shown how to fix the problem by adding a meaning to `--': if `--' is seen, do not do anything dwimmy in the case of 0 or 1 files in the list, treat them like any longer list. The system is very much the same. My solution fixes the problem and I claim it would not break any existing real shell scripts, or upset interactive use, however it would remove many bugs. Now, about the globbing... erik: > if we follow your redesign of unix, we would never get an error because > cat * does nothing and wouldn't be an error at all. "redesign of unix" is overstating it. There should not be an error when a glob or pattern matches nothing. "none" is a perfectly valid reply to the query *.c - what .c files are here? For interactive use, an environment variable WARNIFEMPTY or something could request warnings (or ERRORIFEMPTY for errors) from the shell if a glob expands to nothing; or from commands if a command is run with no files to operate on. Or perhaps we could have a different globber that does the right thing, such as `{glob *} - that would be okay for scripts, and the status quo is tolerable for interactive use. Maybe the regular globbing can't be fixed without breaking stuff - but I don't know of any program that does depend on this bogus misfeature, and I'm sure I could find plenty of scripts that break because of it... and it's no good to blame the writers of those scripts, it is a clear fault in the system. I don't admire the various god-awful hacks proposed to avoid pitfalls stemming these bugs. Sam