Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16417 > unrolled thread
| Started by | Lawrence Velázquez <vq@larryv.me> |
|---|---|
| First post | 2020-06-20 13:28 -0400 |
| Last post | 2020-06-20 13:28 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to gnu.bash.bug
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Bug on bash shell - $PWD (and consequentely prompt) not updated while renaming current folder. Lawrence Velázquez <vq@larryv.me> - 2020-06-20 13:28 -0400
| From | Lawrence Velázquez <vq@larryv.me> |
|---|---|
| Date | 2020-06-20 13:28 -0400 |
| Subject | Re: Bug on bash shell - $PWD (and consequentely prompt) not updated while renaming current folder. |
| Message-ID | <mailman.167.1592674091.2574.bug-bash@gnu.org> |
> On Jun 20, 2020, at 11:26 AM, Ilkka Virta <itvirta@iki.fi> wrote: > >> On 20.6. 3.51, correio@goncalo.pt wrote: >> >> When we rename the current working directory, $PWD doesn't get updated >> as it would as it would if we just did a simple "cd directory". Fix: >> Probably: Trigger the current working directory refresh event, like it >> is already done with the cd command. Because we can be renaming our own >> current working directory, so a simple trigger is needed when mv is >> executed and renaming the current working directory. At the same time, > > The directory can get renamed by some completely unrelated background > process, without any action from the shell, so you'd need to recheck > it every time the prompt is printed, not just when a particular > command, or any command, is launched. (The name of the directory > could even change while the shell is waiting for a command line to > be input.) > > Running cd . should reset PWD to show the new name, and if you > need that often, I suppose you could run it from PROMPT_COMMAND: > > /tmp$ PROMPT_COMMAND='cd .' > /tmp$ mkdir old > /tmp$ cd old > /tmp/old$ mv /tmp/old /tmp/new > /tmp/new$ echo $PWD > /tmp/new 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. vq
Back to top | Article view | gnu.bash.bug
csiph-web