PATH bug?

Larry Auton lda at bonnie.UUCP
Fri Aug 9 23:03:39 AEST 1985


In article <2562 at sun.uucp> guy at sun.uucp (Guy Harris) writes:
>> If the current directory is specified as the last directory searched using
>> a trailing ":" instead of ":." (in $PATH) then sh will not find executable
>> files in the current directory.
>> 
>> The problem only seems to occur when the current directory is searched last.
>> 
>.... I.e., it doesn't know the difference between
>
>	/bin:/usr/bin
>
>and
>
>	/bin:/usr/bin:
>
>The fix should be obvious (look in "service.c") - unless this is a feature,
>not a bug...
>
>	Guy Harris

If you consider the ':' in the PATH to be the terminator, and the
end of the string to be a terminator only by necessity (i.e. convenience),
then the "bug is not a bug".  If

	PATH=:/bin:/usr/bin

then the first component in the string is NULL, and thus by default,
points to the current directory.  If

	PATH=/bin::/usr/bin

Then the second component is NULL, and the current directory is searched.
Finally, if

	PATH=/bin:/usr/bin:

then there *is no third component to the path*, and so the current
directory is not searched.  It's only a convenience to the user to
allow paths that do not end with a ':'.  All paths "should" end with
a ':', just as all interrogatory sentences "should" end with a '?'.

See what I mean
-- 
Larry Auton
(201)386-4272
ihnp4!bonnie!lda



More information about the Net.bugs.usg mailing list