NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/59602: sh produced unwanted diagnostic



The following reply was made to PR bin/59602; it has been noted by GNATS.

From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: bin/59602: sh produced unwanted diagnostic
Date: Tue, 19 Aug 2025 02:12:52 +0700

     Date:        Mon, 18 Aug 2025 16:55:01 +0000 (UTC)
     From:        christos%zoulas.com@localhost
     Message-ID:  <20250818165501.0BF2A1A923E%mollari.NetBSD.org@localhost>
 
   | >Fix:
   | 	Don't complain when changing directory if you can't determine
   | 	the current working directory?
 
 Not quite, the message is needed, but should only be issued when -e
 is given.   I just forgot that test...   (fixed now).
 
 And:
 
 gnats-admin%NetBSD.org@localhost (really Martin Husemann <martin%duskware.de@localhost>) said:
   |  I am not sure this behaviour is better or worse than before (or if it
   |  should be restricted to interactive mode).
 
 As implemented it was wrong - it was also wrong before the message was
 added, it just needs to be there only when cd exits with a failure
 status in this case, and that only happens with the (relatively new) -e
 option.
 
 
 christos%zoulas.com@localhost said:
   | The error is more confusing for me; did the operation succeed or did it fail
   | (it  succeeded).
 
 Yes, that is why the message should not be produced in this case
 (though a later pwd will fail, and PWD will be unset).
 
 Note that when used with -e, this goes back to being an error, even
 though (when the status is 1, not >= 2) the current directory has
 changed.   This is all as POSIX specifies - though as just about nothing
 actually uses the -e option to cd, it makes little difference.
 
 christos%zoulas.com@localhost said:
   | And if the shell was smarter, it could avoid doing a full getcwd() in
   | that case because it can still stat("foo") and stat("foo/bar") and
   | determine that they are both directories
 
 It could, but that would be kind of pointless, the chdir("foo/bar")
 succeeding provides that information without extra stat() calls.
 
 
 christos%zoulas.com@localhost said:
   | append the right path to $PWD for example  (I am not suggesting to do this,
 
 Good, as that would be part way in the direction of going back to
 pretending to kind of support cd -L - and that's something I don't
 want to even contemplate (it is just too evil for words).
  
   | but I don't see why we need to do getcwd()  for chdir()).
 
 It needs to set PWD, and that needs to be the canonical path, so while
 it could append the relative path to PWD, it would then need to run
 realpath() on the result, which would fail in just the same way as
 getcwd() does.   That's just more work for no gain.
 
 kre
 


Home | Main Index | Thread Index | Old Index