NetBSD Problem Report #45390

From dholland@macaran.localdomain  Wed Sep 21 22:14:37 2011
Return-Path: <dholland@macaran.localdomain>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id CEB3063B884
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 21 Sep 2011 22:14:36 +0000 (UTC)
Message-Id: <20110921221616.6EED26E1D9@macaran.localdomain>
Date: Wed, 21 Sep 2011 18:16:16 -0400 (EDT)
From: dholland@eecs.harvard.edu
Reply-To: dholland@eecs.harvard.edu
To: gnats-bugs@gnats.NetBSD.org
Subject: more sh/$PWD follies
X-Send-Pr-Version: 3.95

>Number:         45390
>Category:       bin
>Synopsis:       more sh/$PWD follies
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kre
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Sep 21 22:15:00 +0000 2011
>Closed-Date:    Mon Mar 21 02:37:29 +0000 2022
>Last-Modified:  Mon Mar 21 02:37:29 +0000 2022
>Originator:     David A. Holland
>Release:        NetBSD 5.99.49
>Organization:
>Environment:
System: NetBSD macaran 5.99.49 NetBSD 5.99.49 (MACARAN) #8: Mon Apr 11 19:54:18 EDT 2011 dholland@macaran:/usr/src/sys/arch/amd64/compile/MACARAN amd64
Architecture: x86_64
Machine: amd64

/bin/sh:
     $NetBSD: crt0-common.c,v 1.5 2011/03/07 05:09:09 joerg Exp $
     $NetBSD: crt0.S,v 1.1 2010/08/07 18:01:34 joerg Exp $
     $NetBSD: crti.S,v 1.1 2010/08/07 18:01:35 joerg Exp $
     $NetBSD: crtbegin.S,v 1.2 2010/11/30 18:37:59 joerg Exp $
     $NetBSD: alias.c,v 1.13 2010/10/29 17:04:48 stacktic Exp $
     $NetBSD: cd.c,v 1.41 2011/02/17 15:13:49 pooka Exp $
     $NetBSD: echo.c,v 1.14 2008/10/12 01:40:37 dholland Exp $
     $NetBSD: error.c,v 1.37 2008/10/16 14:36:40 dholland Exp $
     $NetBSD: eval.c,v 1.101 2011/02/17 15:13:49 pooka Exp $
     $NetBSD: exec.c,v 1.42 2008/10/16 15:31:05 dholland Exp $
     $NetBSD: expand.c,v 1.83 2009/11/27 10:50:04 tsutsui Exp $
     $NetBSD: histedit.c,v 1.42 2011/01/07 22:21:56 jmmv Exp $
     $NetBSD: input.c,v 1.44 2011/02/17 15:13:49 pooka Exp $
     $NetBSD: jobs.c,v 1.68 2008/12/21 17:16:11 christos Exp $
     $NetBSD: mail.c,v 1.16 2003/08/07 09:05:33 agc Exp $
     $NetBSD: main.c,v 1.56 2010/02/21 09:54:57 christos Exp $
     $NetBSD: memalloc.c,v 1.29 2008/02/15 17:26:06 matt Exp $
     $NetBSD: miscbltin.c,v 1.38 2009/03/29 01:02:49 mrg Exp $
     $NetBSD: mystring.c,v 1.16 2003/08/07 09:05:35 agc Exp $
     $NetBSD: options.c,v 1.41 2009/01/18 00:30:54 lukem Exp $
     $NetBSD: parser.c,v 1.79 2010/12/13 16:54:04 christos Exp $
     $NetBSD: redir.c,v 1.31 2011/02/17 15:13:49 pooka Exp $
     $NetBSD: show.c,v 1.27 2010/11/14 19:36:07 christos Exp $
     $NetBSD: trap.c,v 1.34 2008/02/15 17:26:06 matt Exp $
     $NetBSD: output.c,v 1.33 2010/08/30 06:27:14 christos Exp $
     $NetBSD: var.c,v 1.39 2008/10/16 14:36:40 dholland Exp $
     $NetBSD: test.c,v 1.37 2008/09/10 19:00:51 christos Exp $
     $NetBSD: kill.c,v 1.26 2009/10/01 09:24:38 spz Exp $
     $NetBSD: syntax.c,v 1.2 2007/12/12 22:55:43 lukem Exp $
     $NetBSD: arith.y,v 1.19 2009/11/13 13:49:09 gson Exp $
     $NetBSD: arith_lex.l,v 1.15 2009/10/29 14:21:40 christos Exp $
     $NetBSD: printf.c,v 1.35 2011/03/15 23:11:49 christos Exp $
     $NetBSD: crtend.S,v 1.1 2010/08/07 18:01:34 joerg Exp $
     $NetBSD: crtn.S,v 1.1 2010/08/07 18:01:35 joerg Exp $

>Description:

Because of kshisms that have been allowed to creep into POSIX, sh
sports some complications pertaining to cd, pwd, and the $PWD
environment variable.

I remember some time ago editing the documentation after a lengthy
argument in tech-userlevel, so I believe the behavior of the program
should be updated to match the man page.

To wit:

 - pwd is supposed to accept both -L and -R options, but the -R option
   is not accepted:
	% mkdir /tmp/foo
	% env PWD= sh -c 'cd /tmp/foo; pwd -R'
	pwd: Illegal option -R
	Exit 2
	% 

 - while cd -L is not supported, cd is supposed to accept the -R
   option, which is the default, but it doesn't:
	% sh -c 'cd -R /'
	cd: Illegal option -R
	Exit 2
	% 

 - cd is supposed to print the name of the directory it changes into
   if it is not the name given, and the shell is interactive, but it
   does not:
	% mkdir /tmp/foo
	% mkdir /tmp/foo/test
	% ln -s test /tmp/foo/link
	% sh -i
	$ cd /tmp/foo/link
	$ /bin/pwd
	/tmp/foo/test
	$ exit
        % 

 - pwd -L is not supposed to print the cached internal value (which is
   related to but separate from $PWD) unless it names the current
   directory. However, at least in some circumstances it will, such as
   this:
	% mkdir /tmp/foo
	% mkdir /tmp/foo/alpha
	% mkdir /tmp/foo/beta
	% env PWD= sh -c 'cd /tmp/foo/beta; mv /tmp/foo/beta /tmp/foo/alpha/beta; pwd'
	/tmp/foo/beta
	% 

 - cd is supposed to both change to the named directory and update
   $PWD with it, but it does not always do this correctly:
	% mkdir /tmp/foo
	% mkdir /tmp/foo/alpha
	% mkdir /tmp/foo/beta
	% env PWD= sh -c 'cd /tmp/foo/beta; mv /tmp/foo/beta /tmp/foo/alpha/beta; cd ..; echo $PWD'
	/tmp/foo
	% 
   (In this case the internal cached value used by the pwd builtin is also
   incorrectly set to /tmp/foo and then also, as in the previous example,
   incorrectly printed.)


Also, the man page is not explicit about what "update PWD with the
specified directory" actually means if the specified directory is not
absolute. The wording needs to be improved.

Since I wrote that text, I'm allowed to say what I intended, which is
that PWD be updated with the/a name for the specified physical
directory, not that the value of $PWD should be used in preference to
reality when it's wrong, updated relatively, and then used in a
chdir() call. ksh will do the latter in at least some circumstances
but it's clearly broken:
	% mkdir /tmp/foo
	% mkdir /tmp/foo/alpha
	% mkdir /tmp/foo/beta
	% env PWD= ksh -c 'cd /tmp/foo/beta; mv /tmp/foo/beta /tmp/foo/alpha/beta; echo $PWD; /bin/pwd; cd ..; echo $PWD; /bin/pwd'
	/tmp/foo/beta
	/tmp/foo/alpha/beta
	/tmp/foo
	/tmp/foo
	% 

>How-To-Repeat:

as above.

>Fix:

don't have time this week, maybe later.


>Release-Note:

>Audit-Trail:
From: Alan Barrett <apb@cequrux.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/45390: more sh/$PWD follies
Date: Fri, 23 Sep 2011 21:54:19 +0200

 On Wed, 21 Sep 2011, dholland@eecs.harvard.edu wrote:
 > - pwd is supposed to accept both -L and -R options, but the -R option
 >   is not accepted:
 >	% mkdir /tmp/foo
 >	% env PWD= sh -c 'cd /tmp/foo; pwd -R'
 >	pwd: Illegal option -R
 >	Exit 2
 >	%

 Did you mean "pwd -P"?  That seems to work.

 > - while cd -L is not supported, cd is supposed to accept the -R
 >   option, which is the default, but it doesn't:
 >	% sh -c 'cd -R /'
 >	cd: Illegal option -R
 >	Exit 2
 >	%

 Here too, I think you meant "cd -P", not "cd -R".

 > - cd is supposed to print the name of the directory it changes into
 >   if it is not the name given, and the shell is interactive, but it
 >   does not:
 >	% mkdir /tmp/foo
 >	% mkdir /tmp/foo/test
 >	% ln -s test /tmp/foo/link
 >	% sh -i
 >	$ cd /tmp/foo/link
 >	$ /bin/pwd
 >	/tmp/foo/test
 >	$ exit
 >        %

 I'd argue that the cd command really did chdir to /tmp/foo/link.  That's
 the string it passed to the syscall.

 > - pwd -L is not supposed to print the cached internal value (which is
 >   related to but separate from $PWD) unless it names the current
 >   directory. However, at least in some circumstances it will, such as
 >   this:
 >	% mkdir /tmp/foo
 >	% mkdir /tmp/foo/alpha
 >	% mkdir /tmp/foo/beta
 >	% env PWD= sh -c 'cd /tmp/foo/beta; mv /tmp/foo/beta /tmp/foo/alpha/beta; pwd'
 >	/tmp/foo/beta
 >	%

 That's a bug.

 > - cd is supposed to both change to the named directory and update
 >   $PWD with it, but it does not always do this correctly:
 >	% mkdir /tmp/foo
 >	% mkdir /tmp/foo/alpha
 >	% mkdir /tmp/foo/beta
 >	% env PWD= sh -c 'cd /tmp/foo/beta; mv /tmp/foo/beta /tmp/foo/alpha/beta; cd ..; echo $PWD'
 >	/tmp/foo
 >	%
 >   (In this case the internal cached value used by the pwd builtin is also
 >   incorrectly set to /tmp/foo and then also, as in the previous example,
 >   incorrectly printed.)

 There's at least one bug there.  According to
 <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cd.html>,
 "cd -L" is supposed to be the default, and "cd -L .." would legitimately
 end up in /tmp/foo, by performing string manipulation on $PWD.  NetBSD
 /bin/sh does not support "cd -L", and even if it did support it, I think
 it's really confusing for "cd -L" to be the default.

 >Also, the man page is not explicit about what "update PWD with the
 >specified directory" actually means if the specified directory is not
 >absolute. The wording needs to be improved.
 >
 >Since I wrote that text, I'm allowed to say what I intended, which is
 >that PWD be updated with the/a name for the specified physical
 >directory, not that the value of $PWD should be used in preference to
 >reality when it's wrong, updated relatively, and then used in a
 >chdir() call. ksh will do the latter in at least some circumstances
 >but it's clearly broken:

 I agree.  But POSIX specifies the broken behaviour, unless you use
 "cd -P".

 --apb (Alan Barrett)

Responsible-Changed-From-To: bin-bug-people->kre
Responsible-Changed-By: kre@NetBSD.org
Responsible-Changed-When: Wed, 27 Oct 2021 19:50:32 +0000
Responsible-Changed-Why:
I am looking into this PR


From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/45390: more sh/$PWD follies
Date: Thu, 28 Oct 2021 04:53:57 +0700

 apb (back in 2011) replied to most of this PR.   Since then it has languished.

 The first and second reported follies were user finger/memory trouble.

 The third:

  - cd is supposed to print the name of the directory it changes into
    if it is not the name given, and the shell is interactive, but it
    does not:

 does not match what POSIX specifies, which is:

 STDOUT
     If a non-empty directory name from CDPATH is used, or if the operand '-'
     is used, an absolute pathname of the new working directory shall be
     written to the standard output as follows:

             "%s\n", <new directory>

     Otherwise, there shall be no output.

 Notice nothing about interactive, nor "not the name given" in the sense
 used in the example given in the PR.

 Our man page currently says:

     In an interactive shell, the cd command will print out the name of
     the directory that it actually switched to if this is different
     from the name that the user gave, or always if the cdprint option
     is set.  The destination may be different either because the
     CDPATH mechanism was used or if the replace argument was used.

 [Of course, nothing in POSIX about a cdprint option, that is an ash shell
 extension, and irrelevant here.  The "replace argument" we copied from ksh,
 or so the comments say, and is also not in POSIX, but printing in that case
 is consistent with the objective.]

 I plan on changing out man page to be:

      In an interactive shell, or if the posix option is set, the cd
      command will print out the name of the directory that it actually
      switched to if this is different from the name that the user gave,
      or if the cdprint option is set.  The destination may be different
      because a non-empty element of the CDPATH mechanism was used, or
      because the replace argument was used, or because the directory
      parameter was specified as "-".

 This will make sh posix conformant in this area, if in posix mode -- almost
 all other shells simply ignore "interactive" for this, and print, whether or
 not ... but for compat with our existing behaviour, I am currently planning
 on only adding the "|| posix" to the test for interactive, not simply removing
 the latter.

    [Aside: what cd really tests is the 'i' option, which gets set automatically
     in interactive shells, but can also be turned on and off, with very little
     other effect, any time at all.]

 There will also be a small change to the way that the "CDPATH mechanism
 was used" test, but it is quite unlikely that that difference will be
 noticed by almost anyone.   Aside from the man page not mentioning the "-"
 case (it is implemented like that already), adding the test of posix mode
 as an alternative to interactive, and the minor CDPATH use test change, this
 is what we have now.

 Note: I am not saying that the implmentation is as it was in 2011 when
 the PR was filed, there have been changes in this area in the past decade,
 but there don't seem to be any specific source changes required any more
 just to fix anything in the PR.

 There is one more issue here - note that POSIX requires "an absolute
 pathname" to be written - which is clearly not always possible (and POSIX
 needs to be fixed, I plan on filing a bug report with them about it).
 Most other shells simply write the (usually in this case) relative path
 name used (not the user's arg, if it was that, there would be no output,
 so we're in a case where CDPATH was used - the "-" and replace cases both
 result in absolute path names, so will rarely succeed, without allowing
 the path name to be discovered).   Some shells (sometimes) write an error
 or warning message, but no path name in that case (that's what we have
 been doing), zsh pretends a relative path is absolute, and writes that
 (which is beyond dumb, and probably just a bug) and yash hopes that PWD
 (if set) was correct, and uses that to deduce the new absolute path name
 (which is clever, though only a guess, and more work than this obscure
 case is worth).   I plan on copying most of the other shells and writing
 whatever path we have available (the path actually passed to chdir(2))
 when we cannot determine the absolute path.   My guess is (because of the
 divergence of what happens) POSIX will end up saying that it is unspecifed
 what, if anything, will be output in this case.


 The fourth folly:

  - pwd -L is not supposed to print the cached internal value (which is
    related to but separate from $PWD) unless it names the current
    directory. However, at least in some circumstances it will, such as
    this:

 As apb said, that one is a bug.   I have that fixed in my private sources
 (not yet committed).   As the example in the PR might indicate, it isn't
 a bug that anyone is going to encounter very often!

 Also on this one, relating to the note in the PR
 	the cached internal value (which is
         related to but separate from $PWD)
 that is correct, they are separate, but they're only ever different
 if the user (or script) has modified PWD - and POSIX says that if that
 happens, what cd and pwd end up doing is unspecified, so the difference
 isn't really material.   This paragraph isn't really material to the PR
 either of course, just an observation.

 And the fifth (and final?) folly:

  - cd is supposed to both change to the named directory and update
    $PWD with it, but it does not always do this correctly:

 This one was fixed as part of an earlier cd cleanup (sometime before
 NetBSD 8 I believe), and the example given seems to work correctly
 to me in all currently supported shells.


 There's one more issue in the PR, (perhaps not classified as a folly,
 that isn't clear):

 	Also, the man page is not explicit about what "update PWD with the
 	specified directory" actually means if the specified directory is not
 	absolute. The wording needs to be improved.

 Our man page currently says (I didn't check what it said in 2011):

      The -P option instructs the shell to update PWD with the specified
      physical directory path and change to that directory.  This is the
      default.

 I agree that is (still) not as clear as it could be, and propose changing
 it to be:

      The -P option (which is the unalterable default in this sh)
      instructs the shell to change to the directory specified (or
      determined) and if successful update PWD with the new physical
      directory path.  That is the path name, not traversing any
      symbolic links, of the altered working directory of the shell.

 (The man page also says that we do not support the -L option, I have no
 plans to alter that, either in the code or the man page, it also mentions
 that OLDPWD gets updated, which needs no alteration.)

 In the forthcoming edition, POSIX is going to add a new option, -e, to cd.
 This is already supported by a few shells (including FreeBSD's, but also
 bash and mksh), its purpose is to allow cd to exit(1) if it successfully
 changes directory, but is unable to determine the new path for PWD.
 Without this option, cd is required to exit(0) if the directory is changed
 (regardless of what happens to PWD, or any output that might be printed).

 I have implemented this new option, which will be documented as:

       The -e option alters the interpretation of the exit status.  cd
       will exit with status 0 upon complete success.  If the directory
       was successfully changed, but PWD was unable to be updated, cd
       will exit with status 1 if the -e option was given, and status 0
       otherwise.  Upon any other error, including usage errors, and
       failing to successfully change directory, cd will exit with status 2.

 POSIX is not as specific on what the status will be, without -e, our "2"
 is just required to be >0, with -e, it is required to be >1 - as we always
 use status 2 for internal shell detected errors, and 2>0 and 2>1 this all
 just magically works!

 Lastly, there has been some discussion on the austin group lists about
 forcing (most) utilities that write to stdout to actually check the status
 of that output and exit(1) on write failure.   cd would not be one such
 (errors writing the new directory name will continue to be ignored),  but
 pwd is included.

 The effect is that very few POSIX specified utilities which write to
 stdout will be able to simply
 	do { stuff; } while (!finished); printf(whatever); exit(0);
 they will be required to (if no other errors have occurred) insert
 	fflush(stdout);
 	if (ferror(stdout))
 		 fprintf(stderr, "output error\n"), exit(1);
 before the
 	exit(0);

 [I believe some versions of linux libc stdio install an atexit() routine
 which does the all this, so there is no need to modify the applications, but
 that kind of hidden alteration to the exit status is evil.   It obviously
 doesn't help with shell builtins, for which there is no real exit().]

 IMO this is going too far (I don't much care about pwd, having it exit(1)
 in case of a write error is easy, and it isn't hard to argue that
 echo and printf should be the same (the shell's builtin echo already does
 that, has for a long time, though /bin/echo doesn't).   But for most commands
 which do something, and merely incidentally write output, it isn't really.

 This is relevant (just barely) here, as it is related to the shell's pwd
 which is one of the issues of the PR...

 I did a (private) change to the shell's pwd to make this happen for it,
 when it was being discussed on the austin list (it's just a couple of lines)
 but as it is intended to apply to almost everything, I thought I'd make it
 more general, and apply to all of the sh builtin commands (if nothing is
 written to stdout, flushing it and checking for error is harmless).  But
 then I started seeing all the exceptions that would need to be handled for
 this to be sane ... I thought of modifying our (shell source) builtins
 description file (unless you look at sh sources you never see this) to add
 a new option for "check stdout" which itself would be easy - but that change
 then needs to be passed back to where the builtin is being executed, and
 doing that would require changes all over.   So I just gave up, and removed
 everything related.   I could put back the pwd check though if it is considered
 useful -- personally I have never seen a script check the exit status of
 any command which simply writes info to stdout, nor are write errors to
 stdout almost ever experienced (other than EPIPE, which usually turns into
 SIGPIPE, and so is rarely seen as an exit status).   This issue was raised
 by someone doing torture tests on a linux system running
 	pwd >/dev/full; echo $0
 and getting 0 (from mksh I think on the system in question).   (/dev/full
 simply returns ENOSPC to any write attempt, no idea what it does on reads).

 I will wait a day or two to see if there are any comments on all of this
 before committing the changes referred to above, or perhaps changing some
 of them first.

 kre

From: "Robert Elz" <kre@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/45390 CVS commit: src/bin/sh
Date: Sun, 31 Oct 2021 02:12:01 +0000

 Module Name:	src
 Committed By:	kre
 Date:		Sun Oct 31 02:12:01 UTC 2021

 Modified Files:
 	src/bin/sh: cd.c

 Log Message:
 PR bin/45390 - fix for folly four

 In the pwd builtin, verify that curdir names '.' before
 simply printing it.   Never alter PWD or OLDPWD in the
 pwd command.

 Also while here, implement the (new: coming in POSIX, but has existed
 for a while in several other shells) -e option to cd (with -e, cd -P
 will exit(1) if the chdir() succeeds, but PWD cannot be discovered).

 cd now prints the directory name used (if different from that given,
 or cdprint is on) if interactive or (the new bit)in posix mode.

 Some additional/changed comments added, and a DEBUG mode trace call
 that was accidentally put inside an #if 0 block moved to where it
 can do some good.

 XXX pullup -9


 To generate a diff of this commit:
 cvs rdiff -u -r1.50 -r1.51 src/bin/sh/cd.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Robert Elz" <kre@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/45390 CVS commit: src/bin/sh
Date: Sun, 31 Oct 2021 02:12:08 +0000

 Module Name:	src
 Committed By:	kre
 Date:		Sun Oct 31 02:12:08 UTC 2021

 Modified Files:
 	src/bin/sh: sh.1

 Log Message:
 PR bin/45390

 Be explicit about what happens to PWD after a successful cd command.
 Also be very clear  that "cd" and "cd -P" are the same thing, and
 the only cd variant implemented.

 Also, when it is appropriate to print the new directory after a cd
 command, note that it happens if interactive (as it always has here)
 and also if the posix option is set (for POSIX compat, where "interactive"
 is irrelevant).  Mention that "cd -" is a case where the new directory
 is printed (along with paths relative to a non-empty CDPATH entry,
 and where the "cd old new" (string replacement in curdir) is used.

 While here document the new -e option to cd.

 XXX pullup -9


 To generate a diff of this commit:
 cvs rdiff -u -r1.235 -r1.236 src/bin/sh/sh.1

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->needs-pullups
State-Changed-By: kre@NetBSD.org
State-Changed-When: Sun, 31 Oct 2021 02:17:06 +0000
State-Changed-Why:
Needs pullups to -9


State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: kre@NetBSD.org
State-Changed-When: Fri, 05 Nov 2021 17:42:26 +0000
State-Changed-Why:
pullup-9 #1372 requested.


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/45390 CVS commit: [netbsd-9] src/bin/sh
Date: Sat, 6 Nov 2021 13:42:18 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sat Nov  6 13:42:18 UTC 2021

 Modified Files:
 	src/bin/sh [netbsd-9]: cd.c sh.1

 Log Message:
 Pull up following revision(s) (requested by kre in ticket #1372):

 	bin/sh/sh.1: revision 1.236 (patch)
 	bin/sh/cd.c: revision 1.51

 PR bin/45390 - fix for folly four

 In the pwd builtin, verify that curdir names '.' before
 simply printing it.   Never alter PWD or OLDPWD in the
 pwd command.

 Also while here, implement the (new: coming in POSIX, but has existed
 for a while in several other shells) -e option to cd (with -e, cd -P
 will exit(1) if the chdir() succeeds, but PWD cannot be discovered).
 cd now prints the directory name used (if different from that given,
 or cdprint is on) if interactive or (the new bit)in posix mode.

 Some additional/changed comments added, and a DEBUG mode trace call
 that was accidentally put inside an #if 0 block moved to where it
 can do some good.

 XXX pullup -9

 PR bin/45390

 Be explicit about what happens to PWD after a successful cd command.
 Also be very clear  that "cd" and "cd -P" are the same thing, and
 the only cd variant implemented.
 Also, when it is appropriate to print the new directory after a cd
 command, note that it happens if interactive (as it always has here)
 and also if the posix option is set (for POSIX compat, where "interactive"
 is irrelevant).  Mention that "cd -" is a case where the new directory
 is printed (along with paths relative to a non-empty CDPATH entry,
 and where the "cd old new" (string replacement in curdir) is used.

 While here document the new -e option to cd.

 XXX pullup -9


 To generate a diff of this commit:
 cvs rdiff -u -r1.50 -r1.50.8.1 src/bin/sh/cd.c
 cvs rdiff -u -r1.223.2.1 -r1.223.2.2 src/bin/sh/sh.1

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->feedback
State-Changed-By: kre@NetBSD.org
State-Changed-When: Sat, 06 Nov 2021 14:28:24 +0000
State-Changed-Why:
Pullup completed.

Is this issue satisfactorily resolved now?


State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Mon, 21 Mar 2022 02:37:29 +0000
State-Changed-Why:
Yes, it's fine.

Back around the time I filed this I had my nose very out of joint over
ksh's bizarre and broken behavior getting imported into sh.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.