Bug 72363 - sh pathname simplification breaks cd
Summary: sh pathname simplification breaks cd
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: bash   
(Show other bugs)
Version: 8.0
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Tim Waugh
QA Contact: Ben Levenson
: 76049 (view as bug list)
Depends On:
TreeView+ depends on / blocked
Reported: 2002-08-23 07:23 UTC by Alexandre Oliva
Modified: 2007-04-18 16:45 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-12-26 00:58:52 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

Description Alexandre Oliva 2002-08-23 07:23:50 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020809

Description of problem:
when bash is invoked as sh (as in a number of scripts), it performs pathname
simplifications that break some non-trivial but not unreasonable soft-link
patterns.  This is a regression from Red Hat Linux 7.3.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1.mkdir -p x other/this/dir
2.ln -s ../other/this x/y
3.sh -c 'cd x/y/../this/dir'

Actual Results:  the cd command fails:
sh: line 1: cd: x/y/../this/dir: No such file or directory

Expected Results:  it should work, just like it does if sh is invoked as bash,
or if cd -P is used.

Additional info:

The problem has nothing to do with CDPATH, or with non-full pathnames as
arguments to cd.  In fact, I first ran into the problem using full pathnames.

strace indicates it simplifies x/y/.. to x before stating x/this, which is
wrong, since x/y/.. != x

Comment 1 Tim Waugh 2002-10-16 07:42:33 UTC
Changing product.

Comment 2 Tim Waugh 2002-10-16 07:42:48 UTC
*** Bug 76049 has been marked as a duplicate of this bug. ***

Comment 3 Alexandre Oliva 2002-12-26 00:58:52 UTC
Chet Ramey says:

The behavior described in this report is required by POSIX.2.  Read the
description of `canonical form' in

Bash does not do this by default; it's part of the bash posix mode.  It's
documented in the bash info manual:

 32. When the `cd' builtin is invoked in LOGICAL mode, and the pathname
constructed from `$PWD' and the directory name supplied as an argument does not
refer to an existing directory, `cd' will fail instead of falling back to

Since bash goes into posix mode when invoked as `sh', and logical mode is the
default, you'll get this behavior whenever bash is invoked as sh, unless you do
`set -o physical' somewhere.

Note You need to log in before you can comment on or make changes to this bug.