Path: utzoo!utgpu!water!watmath!clyde!cbosgd!mandrill!hal!ncoast!allbery
From: allbery@ncoast.UUCP (Brandon Allbery)
Newsgroups: comp.unix.wizards
Subject: Re: Command interfaces
Message-ID: <6423@ncoast.UUCP>
Date: 14 Dec 87 21:41:27 GMT
References: <1257@boulder.Colorado.EDU> <6840002@hpcllmv.HP.COM> <9555@mimsy.UUCP> <17130@bu-cs.BU.EDU> <450@cresswell.quintus.UUCP>
Reply-To: allbery@ncoast.UUCP (Brandon Allbery)
Followup-To: comp.unix.wizards
Organization: Cleveland Public Access UN*X, Cleveland, Oh
Lines: 43

As quoted from <450@cresswell.quintus.UUCP> by ok@quintus.UUCP (Richard A. O'Keefe):
+---------------
| If you haven't got xargs, or if you don't trust the one you've got,
| you can change the sed script slightly and pipe it into the shell:
| 
| 	ls | sed -n -e 's^/foo\(.*\).x$/mv & baz\1.y/p' | sh -f
| 	-------------------###########--##---#######-----------
| 
| The "-f" here suppresses file-name expansion in the shell.
| You can insert "pick" as another pipe-line stage to make it interactive.
+---------------
| This touches on a user interface topic that I haven't seen mentioned yet,
| which is that when I am about to do something complicated I like to build
| the command up in small steps, testing it as I go.  I was about to say that
| this is orthogonal to the globbing in the shell/in the command question,
| but in fact it ISN'T.  Because what I want is to be able to see exactly
| what command will be executed and with exactly which arguments, *without*
| actually running the command.  (In fact, at the time I test the script,
| the command may well not be written yet.)  If you never write anything
+---------------

If you look at both the segments quoted above, you'll have the answer.  Use
"sh -nf", of course.

Yes, I use an editor to do this.  In any case, "doit" is the way to go,
although I usually put the list of files into a file and fire up an Emacs
on it (which lets me notice that I accidentally included "precious.c"), then
"sh" the result.  I've constructed not only commands but Makefiles from this
(and in one un-memorable case, a UNIX-PC Office menu of my MH folders...).

No matter what technique you name, some people will like it and some people
won't.  Unfortunately, changing it on the fly is impossible because many
of the alternatives require rewriting most of the system programs....  Maybe
a per-user shared library containing a personalized "getopt" clone which also
does globbing?  No, I suspect that most general way is "sh"; if the user
REALLY wants it, a script can be written for commands which want to do their
own globbing (an alias would be better, since you could quote the globbable
arguments).  PERHAPS add a way to suppress globbing... on shell scripts,
aliases, or functions only.
-- 
Brandon S. Allbery		      necntc!ncoast!allbery@harvard.harvard.edu
 {hoptoad,harvard!necntc,cbosgd,sun!mandrill!hal,uunet!hnsurg3}!ncoast!allbery
			Moderator of comp.sources.misc