DASH Shell discussions
 help / color / mirror / Atom feed
From: Eric Blake <ebb9@byu.net>
To: dash@vger.kernel.org
Subject: bugs in cd
Date: Tue, 14 Jul 2009 21:39:03 +0000 (UTC)	[thread overview]
Message-ID: <loom.20090714T212706-910@post.gmane.org> (raw)

For the cd command, POSIX 2008 requires that after all pathnames in CDPATH have 
been tested and failed in step 5, then step 6 interprets the directory argument 
relative to PWD.  In other words, this demonstrates a bug:

$ dash -c 'cd /tmp; mkdir -p foo; CDPATH=oops; cd foo; echo $?; pwd'
cd: 1: can't cd to foo
2
/tmp

while bash gets it correct:

$ bash -c 'cd /tmp; mkdir -p foo; CDPATH=oops; cd foo; echo $?; pwd'
0
/tmp/foo

Furthermore, POSIX requires that if the element in CDPATH ends in slash, that 
no additional slashes are added while forming the candidate curpath.  In light 
of the fact that //home need not be the same directory as /home (and indeed, on 
cygwin, they are distinct entities), this is also a bug:

$ dash -c 'CDPATH=/; cd home'
//home
$ bash -c 'CDPATH=/; cd home'
/home

-- 
Eric Blake



             reply	other threads:[~2009-07-14 21:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-14 21:39 Eric Blake [this message]
2009-08-31 11:28 ` bugs in cd Eric Blake
2009-08-31 12:07 ` Herbert Xu
2009-08-31 12:18 ` Herbert Xu
2009-08-31 12:23   ` Eric Blake
2009-08-31 12:56     ` Herbert Xu
2009-08-31 14:08       ` Eric Blake
2009-09-18  0:03         ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=loom.20090714T212706-910@post.gmane.org \
    --to=ebb9@byu.net \
    --cc=dash@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox