Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16416

Re: Bug on bash shell - $PWD (and consequentely prompt) not updated while renaming current folder.

From Ilkka Virta <itvirta@iki.fi>
Newsgroups gnu.bash.bug
Subject Re: Bug on bash shell - $PWD (and consequentely prompt) not updated while renaming current folder.
Date 2020-06-20 18:26 +0300
Message-ID <mailman.158.1592666821.2574.bug-bash@gnu.org> (permalink)
References <051e2fbabf3a9912e5d4248efba0f02b@goncalo.pt> <c2a567ac-2c9c-4ebf-f769-3aed25e679cb@iki.fi>

Show all headers | View raw


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


-- 
Ilkka Virta / itvirta@iki.fi

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Bug on bash shell - $PWD (and consequentely prompt) not updated while renaming current folder. Ilkka Virta <itvirta@iki.fi> - 2020-06-20 18:26 +0300

csiph-web