Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000253 [1003.1(2008)/Issue 7] Shell and Utilities Comment Enhancement Request 2010-05-07 03:42 2020-01-31 12:17
Reporter Don Cragun View Status public  
Assigned To ajosey
Priority normal Resolution Accepted  
Status Applied  
Name Don Cragun
Organization Self
User Reference Add -e option to cd utility
Section cd
Page Number 2505-2508
Line Number 80178-80341
Interp Status ---
Final Accepted Text
Summary 0000253: Scripts need to have a way to determine that "cd -P" correctly set the PWD environment variable.
Description During the discussion of bugID 0000240, we noticed that cd -P can set $PWD
and $OLDPWD to unspecified values while returning a zero (successful) exit
status when the caller doesn't have permission to access part of the directory
hierarchy above the target directory. This issue was discussed in austin-group
e-mail alias sequence numbers 13683, 13686, 13688, 13695, 13698, and 13702.

The desired action below adds a new -e option that is only defined for use when
the -P option is also in use. It will cause a specific exit status to be returned when
the setting of$ PWD is not known to be correct. The current unspecified value of
$PWD with exit status zero will not be changed unless this new option is in effect.
Desired Action In the SYNOPSIS section, change:
    cd [−L|−P] [directory]
on P2505, L80178 to:
    cd [−L] [directory]
    cd −P [−e] [directory]


In the DESCRIPTION section, insert a paragraph break in step 10 on P2506, L80239
before the sentence that starts with "If the −P option is in effect" and add the
following at the end of the newly created paragraph:
    If both the −e and the −P options are in effect and cd is unable to determine the
    pathname of the current working directory, cd shall complete successfully but
    return a non-zero exit status.


In the OPTIONS section, insert a new option after P2506, L80248:
    −e      If the −P option is in effect, the current working directory is successfully
            changed, and the correct value of the PWD environment variable cannot be
            determined, exit with exit status 1.


In the EXIT STATUS section, change:
     0      The directory was successfully changed.
    >0      An error occurred.
to:
     0      The current working directory was successfully changed and the value of
            the PWD environment variable was set correctly.
     0      The current working directory was successfully changed, the −e option is
            not in effect, the −P option is in effect, and the correct value of the PWD
            environment variable could not be determined.
    >0      Either the −e option or the −P option is not in effect, and an error occurred.
     1      The current working directory was successfully changed, both the −e and
            the −P options are in effect, and the correct value of the PWD environment
            variable could not be determined.
    >1      Both the −e and the −P options are in effect, and an error occurred.


Add a new paragraph to the end of the RATIONALE section after P2508,
L80341:
    When the −P option is in effect, the correct value of the PWD environment
    variable cannot be determined on some systems, but still results in a zero
    exit status.  The value of the $PWD doesn't matter to some shell scripts
    and in those cases this is not a problem.  In other cases, especially with
    multiple calls to cd, the values of $PWD and $OLDPWD are important but
    the standard provided no easy way to know that this was the case.  The
    −e option has been added, even though this was not historic practice, to
    give script writers a reliable way to know when the value of $PWD is not
    reliable.
Tags issue8
Attached Files

- Relationships

-  Notes
(0000424)
geoffclare (manager)
2010-06-03 15:16

In the June 3rd teleconference we discussed David Korn's alternative
proposal from mail sequence 13900. We identified a problem, in that
when PWD can't be set by cd -P it might be left as a pathname for the
current directory that contains symlinks, in which case the -ef
test would give a "false pass".
(0000888)
wpollock (reporter)
2011-07-09 01:16

Instead of the two line synopsis of:
    cd [−L] [directory]
    cd −P [−e] [directory]
consider using this alternate, more compact format:
    cd [ −L | −P [ -e ] ] [ directory ]
or (if you really don't like the spaces) this:
    cd [−L|−P [-e]] [directory]
(0000891)
geoffclare (manager)
2011-07-11 10:09

(Response to Note: 0000888)

The proposed alternative would be ambiguous.

   cd [−L|−P [-e]] [directory]

could be equivalent to either the two lines:

    cd [−L] [directory]
    cd −P [−e] [directory]

or the three lines:

    cd -L [-e] [directory]
    cd -P [-e] [directory]
    cd [directory]

depending on the precedence of "|". There are existing uses of "|"
that have differing precedence. For example unexpand has:

   [-a|-t tablist]

whereas qalter has:

   [-r y|n]

These cases are not ambiguous because it can be seen from the unexpand
OPTIONS sections that -a does not take an option-argument, and for
qalter if the n was not a -r option-argument it would be an operand,
and it's in the wrong place to be an operand.

- Issue History
Date Modified Username Field Change
2010-05-07 03:42 Don Cragun New Issue
2010-05-07 03:42 Don Cragun Status New => Under Review
2010-05-07 03:42 Don Cragun Assigned To => ajosey
2010-05-07 03:42 Don Cragun Name => Don Cragun
2010-05-07 03:42 Don Cragun Organization => Self
2010-05-07 03:42 Don Cragun User Reference => Add -e option to cd utility
2010-05-07 03:42 Don Cragun Section => cd
2010-05-07 03:42 Don Cragun Page Number => 2505-2508
2010-05-07 03:42 Don Cragun Line Number => 80178-80341
2010-05-07 03:42 Don Cragun Interp Status => ---
2010-05-07 03:45 Don Cragun Desired Action Updated
2010-05-07 14:53 Don Cragun Desired Action Updated
2010-05-09 15:05 Don Cragun Desired Action Updated
2010-06-03 15:16 geoffclare Note Added: 0000424
2010-06-03 15:17 msbrown Final Accepted Text => see Desired Action
2010-06-03 15:17 msbrown Status Under Review => Resolved
2010-06-03 15:17 msbrown Resolution Open => Future Enhancement
2010-09-09 15:48 geoffclare Tag Attached: issue8
2011-07-08 16:24 geoffclare Final Accepted Text see Desired Action =>
2011-07-08 16:24 geoffclare Resolution Future Enhancement => Accepted
2011-07-09 01:16 wpollock Note Added: 0000888
2011-07-11 10:09 geoffclare Note Added: 0000891
2020-01-31 12:17 geoffclare Status Resolved => Applied


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker