Subject: bin/30973: Bug in /bin/sh
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: Andreas Wiese <awiese@despammed.com>
List: netbsd-bugs
Date: 08/11/2005 20:43:00
>Number:         30973
>Category:       bin
>Synopsis:       Setting $CDPATH breaks /bin/sh shell scripts.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 11 20:43:00 +0000 2005
>Originator:     Andreas Wiese
>Release:        NetBSD 3.99.7
>Organization:
	BSD-Crew Dresden, Germany
>Environment:
System: NetBSD schroeder.o-zonenloch.home 3.99.7 NetBSD 3.99.7 (SCHROEDER) #1: Fri Jun 24 00:19:34 CEST 2005 root@schroeder.o-zonenloch.home:/sys/arch/i386/compile/SCHROEDER i386
Architecture: i386
Machine: i386
>Description:
When setting the $CDPATH environment variable, `cd' in shell scripts
doesn't do what it should every time.  I noticed this when running
build.sh from /usr/src via ./build.sh.  With a set $CDPATH it complains
not to be run from /usr/src because it does a "cd `dirname $0`", i.e. it
executes "cd ." and gets to the first directory in $CDPATH.

#v+
aw@schroeder:~> cat test.sh
#!/bin/sh

echo CDPATH=$CDPATH
pwd
cd .
pwd
aw@schroeder:~> ./test.sh
CDPATH=
/home/aw
/home/aw
aw@schroeder:~> export CDPATH=/tmp
aw@schroeder:~> ./test.sh
CDPATH=/tmp
/home/aw
/tmp
aw@schroeder:~>
#v-

With "#!/bin/ksh" or "#!/usr/pkg/bin/zsh" this doesn't happen.

>How-To-Repeat:
See above.

--Q68bSM7Ycu6FN28Q
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (NetBSD)

iD8DBQFC+7gvpxHyXmET8T8RAptLAJ44YxB+5LxdGIuzFmdEY8Yjf8kwygCgsB1W
9hC1NbYke0Io9Qrkl4Tmgqk=
=6e2y
-----END PGP SIGNATURE-----

--Q68bSM7Ycu6FN28Q--

>Fix:

Unknown
>Unformatted:
 --Q68bSM7Ycu6FN28Q
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline