Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!husc6!sri-unix!quintus!ok
From: ok@quintus.UUCP (Richard A. O'Keefe)
Newsgroups: comp.unix.wizards
Subject: Re: shell globbing universal ?????
Message-ID: <438@cresswell.quintus.UUCP>
Date: Sun, 6-Dec-87 01:56:08 EST
Article-I.D.: cresswel.438
Posted: Sun Dec  6 01:56:08 1987
Date-Received: Thu, 10-Dec-87 23:00:45 EST
References: <14107@oddjob.UChicago.EDU> <6793@brl-smoke.ARPA> <8112@steinmetz.steinmetz.UUCP>
Organization: Quintus Computer Systems, Mountain View, CA
Lines: 65
Summary: fixing dd

In article <8112@steinmetz.steinmetz.UUCP>, stpeters@dawn.steinmetz
(Dick St.Peters) wrote:
> In article <6793@brl-smoke.ARPA> gwyn@brl.arpa
> (Doug Gwyn (VLD/VMB) ) writes:
> >In article <14107@oddjob.UChicago.EDU> matt@oddjob.uchicago.edu
> > (Java Man) writes:
> >>o 204% dd if=g*
> >>o 205% set if=g*
> 	[deleted]
> >All this shows is that "dd" ought to be fixed and the Cshell should
> >be stamped out..
> 
> Hell, no!  "Fixing" dd would break an awful lot of scripts, and it's

Fixing dd needn't involve breaking anything.
Last night, as an exercise in sh(1) programming, I wrote a script
	convert-and-copy
which takes arguments like  "-o output" rather than "ofs=output".
It also checks the arguments somewhat more thoroughly than dd.
Total time: 1/2hr to write the script, 1/2hr to debug it.
Result: no scripts are broken, and I have a dd I can live with.
By the way, there is a way to suppress file-name expansion in sh(1):
	set -f
My script has the form
	
	
	set -f
	dd 
So	
	convert-and-copy -i '*.ebc' -t ascii -o '?.asc'
works just fine.

Concerning "set if=g*"; it is not the case that sh(1) gets this
right, rather that it doesn't do what you might expect.  Suppose
you have a directory containing "g=gx" and "g=gx.c", and you type
	$ g=g*
	$ echo $g
You see the output
	g=gx g=gx.c
and think, ah, g="g=gx g=gx.c" just as I expected, and file-name
expansion is done to the bit after the "=".  Wrong.  Try
	$ echo "$g"
and you see the output
	g*
Now the sh(1) manual page (and the SVID) explicitly say that
"filename generation" is not done if the apparent pattern doesn't
match anything, and it does NOT say that there is anything special
about "=".  So another expectation might be that
	$ g=g*
would expand into "g=gx g=gx.c" and then bind g to gx or to gx.c.
I have experimented with this a bit, and it seems that the rule is
	if a word contains an "=" and either
	the "-k" option is set, or the word does not follow a command
	then the word will not be subject to filename generation.
No doubt this is explained somewhere, but I cannot find it in the SVID.
If you want expansion done in the right hand side of a definition,
you have to use
	$ g=`echo g*`
which has its own complications, because some bright helpful person
decided that the System V echo command should interpret "\", and
thought this clever feature was so wonderful that there should be
no way to switch it off.  (Now I know why they call it Missed'em V.)
System's V "echo" is now great for printing messages, but useless
for use in situations like this.  I now have my own program for
echoing.  I just wish AT&T would follow their own rules...