From unknown Wed Jun 18 00:27:02 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#34447 <34447@debbugs.gnu.org> To: bug#34447 <34447@debbugs.gnu.org> Subject: Status: `pwd` doesn't show real working directory if directory is renamed by another session Reply-To: bug#34447 <34447@debbugs.gnu.org> Date: Wed, 18 Jun 2025 07:27:02 +0000 retitle 34447 `pwd` doesn't show real working directory if directory is ren= amed by another session reassign 34447 coreutils submitter 34447 Chris Wright severity 34447 normal tag 34447 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 11 19:34:38 2019 Received: (at submit) by debbugs.gnu.org; 12 Feb 2019 00:34:38 +0000 Received: from localhost ([127.0.0.1]:44262 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gtM22-0002Yb-4a for submit@debbugs.gnu.org; Mon, 11 Feb 2019 19:34:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47790) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gtLK5-0001Ow-QK for submit@debbugs.gnu.org; Mon, 11 Feb 2019 18:49:15 -0500 Received: from lists.gnu.org ([209.51.188.17]:46752) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gtLK0-00089P-CZ for submit@debbugs.gnu.org; Mon, 11 Feb 2019 18:49:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33467) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtLJz-0002aT-3r for bug-coreutils@gnu.org; Mon, 11 Feb 2019 18:49:08 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: *** X-Spam-Status: No, score=3.6 required=5.0 tests=BAYES_50, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RECEIVED_FROM_WINDOWS_HOST autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtL5H-0001cu-Ks for bug-coreutils@gnu.org; Mon, 11 Feb 2019 18:33:57 -0500 Received: from mail-oln040092071049.outbound.protection.outlook.com ([40.92.71.49]:6190 helo=EUR03-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gtL5F-0001ES-4H for bug-coreutils@gnu.org; Mon, 11 Feb 2019 18:33:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IwfcL2BjUDCJyboxdAbzjUY0fDxXvWKYDu7R5vEbl+w=; b=AsxQkHMRyh5o0QOWNKk5JR0nB+6fAR8SbSbbArp7ll2FNDL6lQfb358OGKyvQjF7iKZo0bm9gTwW0fWkb2SFXg18R7Us4IIOys435dIFbLZv1o5dUResaKa/GpIlnqU/n7YKNZKaDD6qhbg+r36+KmxVgT45SBDQ6Lput6IkVr33PMkq/ITP6kBI/GeW+BnFBa7j5jU+KErElZarkZmxKgsdbwNYgDe0GkEyGVElG7SNbrY60Z9q2W5ShhNNmCe3DzbJX80kMIVojuC7TS1dteHsQwudlpQ6nW9a2Hho/DBKlPS3KTm+sSZ0WK0RwvWHGYNFIl9dqJ177AssTVjcZg== Received: from DB5EUR03FT053.eop-EUR03.prod.protection.outlook.com (10.152.20.55) by DB5EUR03HT113.eop-EUR03.prod.protection.outlook.com (10.152.20.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1580.17; Mon, 11 Feb 2019 23:33:15 +0000 Received: from DB7P194MB0443.EURP194.PROD.OUTLOOK.COM (10.152.20.60) by DB5EUR03FT053.mail.protection.outlook.com (10.152.21.119) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1580.17 via Frontend Transport; Mon, 11 Feb 2019 23:33:15 +0000 Received: from DB7P194MB0443.EURP194.PROD.OUTLOOK.COM ([fe80::bcc6:7a25:99e0:569b]) by DB7P194MB0443.EURP194.PROD.OUTLOOK.COM ([fe80::bcc6:7a25:99e0:569b%3]) with mapi id 15.20.1601.023; Mon, 11 Feb 2019 23:33:15 +0000 From: Chris Wright To: "bug-coreutils@gnu.org" Subject: `pwd` doesn't show real working directory if directory is renamed by another session Thread-Topic: `pwd` doesn't show real working directory if directory is renamed by another session Thread-Index: AQHUwmIcD1RHh1Hzskitu/tfQuj4sg== Date: Mon, 11 Feb 2019 23:33:15 +0000 Message-ID: Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:1478F5B9096052B19D582AD887C7661D4B62D61F8A96232E4AFD60A74E61689E; UpperCasedChecksum:C0CCEB4C5ED97446F9F464B4CE29E03DC5D5A0056BDF18581959599EF8F1F720; SizeAsReceived:6902; Count:43 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [4NkSuFBTbHIsjYXu7TE2lJ+MTuaXsS4n] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB5EUR03HT113; 6:qnOK/829snPhNp4zDWyc/IefUxpumMr7ERc6zC9/Y2+htguPYomZKNdfZOjhjglwA8U95KekrjC5YCnovZPOtKDisJz+P+hxF/vAlzfo9cXQYch2uwiwgYKNe2gmM+JIyJrFyw0cCpgUcqCC9Lf5pRMuCDqiVGr6vxY+xXXwRbF/E4IiX7c6hoEQqv3/SqHPaTWFul3aZCTHfb3JAjB/EJe0vFTZEwFRLNICgg3rnLdx2+qG7fxm2Imd9I467u6B4mlvfg0srgiOc0t2bOFr2n6JUwxq1u+Sp7gKhNka7rqeTzwm+9bFKujMncAlwBj00gzAP0M8Y48RhaTYQaRgzAejBAskoub0a2kIQiv1q56FBptr82RiSX0mWVqR72fSgKDckFScpNHOtPMfLvBzBRpSz3ObwZ1Cu/2xUT5KEIQto8GQ/79bb7uW8+07xPMiQRo4MumXPGQvAgkZLrjOlA==; 5:WgbmDogcFU6yHcwIWUKRhwDd0UGmPtmlmDJw6MUa4LVReofMyDQwjYPZfc5F6n4sajBSV779qw+JhsNb0aV1gVABzDRjvipzkugUMFvATk34muFfzzKt51nbgRi+3NbQBAit5sxgm2ci3IlvJu3nXaYGz0mXDUfFNtgXzJRiNBggvAiCuLqhrEX2OZw6DmFUHWy8tYCIWZ7h1EZPE6uTkQ==; 7:64u/Ox3QD7xwhRoL9R7hmvbxqb/M08+ZlVzbNgOgoQky0pGtRobwmKLJrxBJmMEnWwIl4j74jjQLHmpKbEqdNI9r6iJBpxs1qGO4G9VrbucJdSAy56qyOS0t05X9fwHzmQ39TfBi9u+Son7UwXUfKg== x-incomingheadercount: 43 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031323274)(2017031324274)(2017031322404)(1601125500)(1603101475)(1701031045); SRVR:DB5EUR03HT113; x-ms-traffictypediagnostic: DB5EUR03HT113: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(4566010)(82015058); SRVR:DB5EUR03HT113; BCL:0; PCL:0; RULEID:; SRVR:DB5EUR03HT113; x-microsoft-antispam-message-info: GD3gKVRI1kspbGVGDzolIgsoOhKB/vKxVYyT9BmtiAtIHksfJDZP5sjqoWdIrmUE Content-Type: multipart/alternative; boundary="_000_DB7P194MB044377E4C03E8146F6D9BB5AB4640DB7P194MB0443EURP_" MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 5dab7a8a-ebdc-4bd9-9cfd-67cde50b170b X-MS-Exchange-CrossTenant-Network-Message-Id: b2f7828b-a0c5-4ad0-7f2d-08d690794bbd X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 5dab7a8a-ebdc-4bd9-9cfd-67cde50b170b X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Feb 2019 23:33:15.4885 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5EUR03HT113 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.92.71.49 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi, I found that if a session's working directory is renamed or moved, `pwd` doesn't show the real working directory. Example: Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (chriswright96[at]hotmail.com) 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (chriswright96[at]hotmail.com) 0.0 HTML_MESSAGE BODY: HTML included in message X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 11 Feb 2019 19:34:37 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.2 (/) --_000_DB7P194MB044377E4C03E8146F6D9BB5AB4640DB7P194MB0443EURP_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I found that if a session's working directory is renamed or moved, `pwd` do= esn't show the real working directory. Example: Session 1: ``` ~/ $ mkdir test ~/ $ cd test ~/test $ touch file ``` Session 2: ``` ~/ $ mv test test_2 ~/ $ mkdir test ~/ $ cd test ~/ $ touch file2 ~/ $ ls file2 ~/ $ ``` Session 1 (still running during session 2): ``` ~/test $ ls file ~/test $ pwd /Users//test ~/test $ realpath file /Users//test_2/file ~/test $ realpath nonExistenFile /Users//test_2/nonExistenFile ``` It seems that `realpath` does show the updated path, but `pwd` doesn't Tested on MacOS (10.14.3) and Ubuntu 16.04 / 18.04 Thanks, Chris --_000_DB7P194MB044377E4C03E8146F6D9BB5AB4640DB7P194MB0443EURP_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,

I found that if a session's working directory is renamed or moved, `pwd` do= esn't show the real working directory.

Example:

Session 1:

```
~/ $ mkdir test
~/ $ cd test
~/test $ touch file
```

Session 2:

```
~/ $ mv test test_2
~/ $ mkdir test
~/ $ cd test
~/ $ touch file2
~/ $ ls
file2
~/ $
```

Session 1 (still running during session 2):

```
~/test $ ls
file
~/test $ pwd
/Users/<user>/test
~/test $ realpath file
/Users/<user>/test= _2/file
~/test $ realpath nonExi= stenFile
/Users/<user>/test= _2/nonExistenFile=
```

It seems that `realpath` does show the updated path, but `pwd` doesn't

Tested on MacOS (10.14.3) and Ubuntu 16.04 / 18.04

Thanks,
Chris
--_000_DB7P194MB044377E4C03E8146F6D9BB5AB4640DB7P194MB0443EURP_-- From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 22 18:23:43 2019 Received: (at 34447) by debbugs.gnu.org; 22 Feb 2019 23:23:43 +0000 Received: from localhost ([127.0.0.1]:48664 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gxKAQ-0001oO-VR for submit@debbugs.gnu.org; Fri, 22 Feb 2019 18:23:43 -0500 Received: from havoc.proulx.com ([96.88.95.61]:32858) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gxKAO-0001o6-8W; Fri, 22 Feb 2019 18:23:41 -0500 Received: from joseki.proulx.com (localhost [127.0.0.1]) by havoc.proulx.com (Postfix) with ESMTP id 2DAAF18B; Fri, 22 Feb 2019 16:23:34 -0700 (MST) Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id E24072116A; Fri, 22 Feb 2019 16:23:33 -0700 (MST) Received: by hysteria.proulx.com (Postfix, from userid 1000) id D63BF2DC7C; Fri, 22 Feb 2019 16:23:33 -0700 (MST) Date: Fri, 22 Feb 2019 16:23:33 -0700 From: Bob Proulx To: Chris Wright Subject: Re: bug#34447: `pwd` doesn't show real working directory if directory is renamed by another session Message-ID: <20190222160809023820824@bob.proulx.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 34447 Cc: 34447@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tag 34447 + notabug close 34447 thanks Hello Chris, Chris Wright wrote: > I found that if a session's working directory is renamed or moved, > `pwd` doesn't show the real working directory. Thank you for your bug report. However I think the shell's built-in pwd is being confused with the external pwd command. The shell internal command has the behavior your describe, intentionally. The external one in GNU Coreutils does not. > ~/test $ pwd > /Users//test The above is using the internal shell builtin. $ type pwd pwd is a shell builtin $ type -a pwd pwd is a shell builtin pwd is /bin/pwd The bash shell built-in has this to say about the internal pwd. $ help pwd pwd: pwd [-LP] Print the name of the current working directory. Options: -L print the value of $PWD if it names the current working directory -P print the physical directory, without any symbolic links By default, `pwd' behaves as if `-L' were specified. Therefore by default the shell's buitin pwd simply prints out the PWD environment variable, which has not changed. This is to preserve the "logical" (not physical) directory tree based upon how the process got there, intentionally tracking how they got there not where they are. They got there by the path stored in PWD. I hate that behavior. But as with most things I was not consulted. :-} In order to do what you want there are at least three options. One is to use the external coreutils version. The idiom for forcing external commands is using 'env' for it. env pwd Another is adding the -P option. This ignores PWD and returns the physical path. pwd -P And the third (what I do) is to set the shell to always use physical paths. Which is how it behaved before they added logical path tracking in the PWD variable. I have this in my ~/.bashrc file. set -o physical Therefore I have closed this bug report for the purpose of triage of the report in the coreutils tracker since this is really about bash and not coreutils. However please do reply as discussion may continue. We would love to continue the discussion. Note that the coreutils 'pwd' defalts to -P, --physical unless -L, --logical is given explicitly. And that the documentation for the coreutils pwd is subtly different from the bash version: '-L' '--logical' If the contents of the environment variable 'PWD' provide an absolute name of the current directory with no '.' or '..' components, but possibly with symbolic links, then output those contents. Otherwise, fall back to default '-P' handling. '-P' '--physical' Print a fully resolved name for the current directory. That is, all components of the printed name will be actual directory names—none will be symbolic links. If '-L' and '-P' are both given, the last one takes precedence. If neither option is given, then this implementation uses '-P' as the default unless the 'POSIXLY_CORRECT' environment variable is set. Due to shell aliases and built-in 'pwd' functions, using an unadorned 'pwd' interactively or in a script may get you different functionality than that described here. Invoke it via 'env' (i.e., 'env pwd ...') to avoid interference from the shell. Hope this helps! Bob From unknown Wed Jun 18 00:27:02 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 23 Mar 2019 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator