Another bug with csh - `cat /tmp/a`

Michael Greim greim at sbsvax.UUCP
Sun Aug 21 01:56:33 AEST 1988


In article <5144 at vdsvax.steinmetz.ge.com>, barnett at vdsvax.steinmetz.ge.com (Bruce G. Barnett) writes:
> I think I have found another bug with csh (surprise! :-)
> Systems: SunOS 4.0, Ultrix 2.3. any many many more.
> 
[stuff deleted]
> But
> 	`/tmp/a`
> gives:
> 	a: permission denied
> 	: permission denied
> Why two errors?
The text within "`" is tried as a command, this is responsible for
the first error. The result, a Null string, is returned. Then the csh
tries to execute this result, a Null string. As this string does not
start with a "/" csh searches for a file with this name in the directories
specified in your path. It does so by trying to open the file in the
directories of your path. The first try matches (!!). But as this file
is most probably "." it cannot execute it, and
this is responsible for the second error message. The string which is
output, saying what file caused the error may vary with different
implementations of csh or dir library routines. With my machines here,
it is the empty (Null) string.
Yes it is a bug but not only in csh. Csh should realize that the command's first
word is empty. Try "cat ''" and you will get the contents of "." for
the same reason : the first argument to cat is the Null string.
The bug is really with open(2) and/or exec(2).
I had it fixed for some time so that csh did not pass Null strings as
parameters, but had to remove it for some reason, which does not come
to my mind just now. Maybe test(1) did not perform correctly ?
> 
> Now when I try:
> 	`junkname`
> where junkname does not exist, I get:
> 	junkname: Command not found
> 	/usr/ucb/: Permission denied
Should be an effect of the same mechanism.

	-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