Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 May 2002 09:14:32 +0700
From:      oleg dashevskii <be9@be9.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/38442: possible bug in /bin/sh: inconsistency between manpage and real program behaviour
Message-ID:  <20020523091432.5aa8640b.be9@be9.ru>

next in thread | raw e-mail | index | archive | help

>Number:         38442
>Category:       bin
>Synopsis:       possible bug in /bin/sh: inconsistency between manpage and real program behaviour
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 22 19:20:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     oleg dashevskii
>Release:        FreeBSD 4.6-PRERELEASE i386
>Organization:
NSU
>Environment:
System: FreeBSD be9.home.ru 4.6-PRERELEASE FreeBSD 4.6-PRERELEASE #1: Wed May 15 10:22:20 NOVST 2002 od@be9.home.ru:/usr/obj/usr/src/sys/BECHO i386


>Description:
	Quoting from `man sh`:

=== q ===
If directory is not found as a subdirectory of the current directory
(and does not begin with ``/'', ``./'', or ``../''), then the
directories listed in the CDPATH variable will be searched for the
specified directory.
=== end q ===

	Now let us check that:

running /bin/sh:

$ cd
$ pwd
/home/od
$ export CDPATH=/
$ echo $CDPATH
/
$ mkdir 9999
$ cd 9999
cd: can't cd to 9999
$ cd ./9999
cd: can't cd to ./9999
$ cd ../od/9999
cd: can't cd to ../od/9999
$ cd ..
/                          <---- and here must be /home, not "/" !!!
$ pwd
/
$ cd /home/od/9999
$ pwd
/home/od/9999		   <---- works with full path
$ export CDPATH=
$ cd
$ cd 9999
$ pwd
/home/od/9999


So, as we can see, CDPATH is preferred over subdirectories in current
directory, as opposed to the words from the manpage.  Even '..' was
substituted as '/..' which is certainly just '/'!


>How-To-Repeat:

	See above. 

>Fix:

	/usr/src/bin/sh/cd.c should be fixed, I guess.

	Possible workaround is to add "." to the CDPATH, that's what I've
	done. If noone is willing to fix that bug in the code, then
	the manpage should be changed to reflect this "bug-o-feature"
	behavior.

	By the way, zsh doesn't suffer from such a problem.
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020523091432.5aa8640b.be9>