csh weirdness (HELP!)

Chris Torek chris at mimsy.umd.edu
Mon Aug 20 09:27:11 AEST 1990


In article <1990Aug19.011139.13718 at watcgl.waterloo.edu>
idallen at watcgl.waterloo.edu (Ian! D. Allen [CGL]) writes:
>Someone is claming that CSH's "Ambiguous" error is due to different
>handling of the built-in kill vs. /bin/kill.

(You must mean me here.)

>I think not:
>
>    % `echo date`
>    Sat Aug 18 20:10:09 EDT 1990
>    % `echo date foo`
>    `echo date foo`: Ambiguous.

Ah, but this is a symptom of the same thing.

>CSH is just stupid about the number of words that are allowed to
>expand in a command name generated by back-quotes.

This is true; but in

	kill `echo 1 2`

there is exactly one word in the command name.  If you try

	echo `echo 1 2`

(for instance) you get

	1 2

so it is obvious that

>It only allows one word, because it won't re-parse the line for
>arguments

only under some circumstances (specifically, all those that call the
routine `globone' with one of the `words' from the `lexer').

The built-in kill routine (dokill()) is one such place.

The routine that runs ordinary (not built in) commands, however, calls
globone only for av[0], the command name; it calls tglob and glob on
the rest of av.  If dokill called tglob and glob in the same way,
before marching down the argument list looking for `%'s, the built-in
kill would work properly.

>same error here:
>
>    % date >`echo hi hi`
>    `echo hi hi`: Ambiguous.

Again, csh calls globone() for an av[] element following a redirection.

>CSH expects single words in funny places, and that's the error you get
>if you don't comply.

In this case, it is probably a good thing: if you typed

	date > xy*

you probably meant to put the output in the (existing) file `xyzzy',
not into `xylophone' (which you forgot about) with the argument `xyzzy'
passed on to `date'.  (After all, you would not want to clobber the
file with the information you saved about ordering xylophones.  That
xylophone is IMPORTANT! :-) )

>For more entertainment, a huge list of CSH bugs (4.2BSD, but most
>still apply) is available via anonymous ftp from watcgl.waterloo.edu
>as CSHbugs.Z (compressed).

Given the csh souce, no doubt it *has* to be kept compressed. :-)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris
	(New campus phone system, active sometime soon: +1 301 405 2750)



More information about the Comp.unix.wizards mailing list