From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Stalker To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> In-reply-to: <20091005192428.GA24445@nipl.net> References: <20091005192428.GA24445@nipl.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <989.1254776666.1@kryten> Date: Mon, 5 Oct 2009 22:04:26 +0100 Message-ID: <200910052204.aa92451@salmon.maths.tcd.ie> Subject: Re: [9fans] mishandling empty lists - let's fix it Topicbox-Message-UUID: 7f6e6862-ead5-11e9-9d60-3106f5b1d025 I think that you're right to complain, but that you aren't quite complaining about the right thing and are therefore offering the wrong solution. The problem is utilities which take list arguments, but which treat empty lists differently. Shell globbing rules can make this better or worse, depending on context, but the problem is in the semantics of our favourite utilities. In a consistent world `cat' would concatenate 0 files, i.e. ouptut nothing, `chmod 755' would set the permissions of no files to 755, `cp foo/' would move no files to the directory foo, `df' would show free disk space for no filesystems, `kill' would stop no processes, `ln foo/' would hardlink no files into the directory foo, `ls' would list no files (you would use `ls .' for the usual case), `mkdir' would create no directories, `mv foo/' would move no files into the directory foo, `ps -U' would show no users' processes, `rm' would remove no files, and `sh' would execute no scripts in the Bourne shell. None of these would produce errors. These are UNIX examples, but Plan 9 is not much different in this regard. A quick glance shows that somewhere between a third and a half of all the basic utilities have this property. Nothing you do to the shell will change this much. A quick look through shell scripts I've written recently convinces me that almost all of them would break if the basic utilities were modified to treat empty lists consistently, even though only one uses file name globbing in any way. If you really want to fix the problem then the sensible thing to do would be to write new versions of many utilities, with new names, and then write a shell without globbing. For new scripts you would use the new utilities and shell and leave everything else as it is. Is it worth the effort? That's a question which can only be answered by the person who would be doing the work. -- John Stalker School of Mathematics Trinity College Dublin tel +353 1 896 1983 fax +353 1 896 2282