csh (was : CSH Help -- I don't get it ...)

Michael Greim greim at sbsvax.UUCP
Fri Aug 19 02:25:19 AEST 1988


In article <1170005 at otter.hple.hp.com>, pdc at otter.hple.hp.com (Damian Cugley) writes:
< / comp.unix.questions / greim at sbsvax.UUCP (Michael Greim) /   Aug 12, 1988 /
< 
< > [Csh] expands other operands. Try :
< > if ( Gargle* =~ "Gargle"*) then
< > [...]
< > and you will see, that csh filename expands the left operand of "=~".
< 
< By gum, so it does.  Wild.  (I guess the csh designers would reply as the
< left operand of =~ isn't supposed to be a pattern, it can anly be expected
< to act weirdly if it is...  I dunno what I'd've done, maybe an error
< message ('Pattern on left of =~'), or maybe treat the '*' as unmagical?)
< 
< I would suspect the csh programmers never considered that these situations
< would occur often, and didn't bother making csh react to them sensibly...
Maybe.
The csh looks like a program which has been written once and then has been
extended often. A lot of code looks as if it has been added afterwards.
The sequence of expansions is hidden in a mess of routines.
In some place there is something like "sorry that we don't parse" comment.
I think csh would gain a lot of speed, readability, bugfreeness if
it were rewritten. Keith Bostic has announced that csh maybe will be rewritten
for the next Berkeley release. If they find a volunteer. (Not me, except
if somebody pays for it :-).
< 
< 
< > BTW:
< > And why is the pattern not command substituted? Does the manual say
< > so? Should it not be possible to
< >         if ( "$a" =~ *`hostname`*) ...
< > whereas
< >         if ( "$a" == `hostname` ) ...
< > works ??
< 
< Ummm...  Errmmm...  well, the csh man page says command substitution comes
< before filename expansion, but not where =~ patterns come in (it should do,
< though).  I guess the designers of csh thought something like
< 
< 	if ($wombat =~ `cmd file.*`)
< 
< would be more useful more often than having patterns outside the `...`.
This does not work either (in standard csh), although you don't get
an error message.
< 
< (As a user of csh (as opposed to a programmer of csh) I'd've expected the
< filenames in `...` to be expanded, *then* the command executed, *then* the
< patterns involving the output of the command.  This would make both of
< these work - but would need two separate stages of pattern-checking (or
< three?) and would be even more complicated.)
Hm, I might just talk a little about the inner workings of csh :
when csh sees a pattern, it sets a flag, which disables the calling
of a routine, which triggers both command and filename expansion.
It looks more like somebody overlooked it. Or maybe they just
shied the complications you mentioned.

< 
< The problem is the csh 'page' is already too long for the way it is now - I
< had a terrible time ploughing through it for the first time.  It's a big
< enough topic to warrant its own mini-glossary, ToC and/or index.  (Or maybe
< hypertexed like the Emacs info pages?  Then each section could have a
< summary of how X-substitution interacts with Y-substitution without the
< manual seeming repetative.)
The man page is not a tutorial, it should remind you what certain things
do. To learn about csh, or to explain all features there should be a doc
somewhere.
< 
< Anyone like to volunteer to re-write the entire manual?  Just a thought :-) .
Not me!
You won't get it much shorter without omitting something, anyway.

	-mg
-- 
UUCP:  ...!uunet!unido!sbsvax!greim   | Michael T. Greim
       or greim at sbsvax.UUCP           | Universitaet des Saarlandes
CSNET: greim%sbsvax.uucp at Germany.CSnet| FB 10 - Informatik (Dept. of CS)
ARPA:  greim%sbsvax.uucp at uunet.UU.NET | Bau 36, Im Stadtwald 15
voice: +49 681 302 2434               | D-6600 Saarbruecken 11, West Germany

# include <disclaimers/std.h>



More information about the Comp.unix.questions mailing list