Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16419
| From | Chet Ramey <chet.ramey@case.edu> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: Bug on bash shell - $PWD (and consequentely prompt) not updated while renaming current folder. |
| Date | 2020-06-20 14:02 -0400 |
| Organization | ITS, Case Western Reserve University |
| Message-ID | <mailman.169.1592676139.2574.bug-bash@gnu.org> (permalink) |
| References | <051e2fbabf3a9912e5d4248efba0f02b@goncalo.pt> <c2a567ac-2c9c-4ebf-f769-3aed25e679cb@iki.fi> <6BF29BAB-6F57-4D88-85BC-56E1AA14F29F@larryv.me> <4c262650-3c37-923f-53f1-358df8c0f9a1@case.edu> |
On 6/20/20 1:28 PM, Lawrence Velázquez wrote:
> Here's something fun though:
>
> $ PROMPT_COMMAND='cd .'
> $ readlink /tmp
> private/tmp
> $ mkdir /tmp/old
> $ cd /tmp/old
> $ echo "$PWD"
> /tmp/old
> $ mv /tmp/old /tmp/new
> $ echo "$PWD"
> /private/tmp/new
>
> Not wrong, but maybe unexpected to some.
It's a way to make sure PWD is correct after a `cd'. Without options, `cd'
canonicalizes its pathname argument in the way POSIX describes in
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/cd.html#tag_20_14
That converts it to /tmp/old ("." -> "/tmp/old/." -> "/tmp/old")
Since chdir to "/tmp/old" fails, bash falls back to chdir to ".", which
succeeds, and then recanonicalizes PWD to the true directory pathname, as
would be returned by `pwd -P'.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
Back to gnu.bash.bug | Previous | Next | Find similar
Re: Bug on bash shell - $PWD (and consequentely prompt) not updated while renaming current folder. Chet Ramey <chet.ramey@case.edu> - 2020-06-20 14:02 -0400
csiph-web