Path: csiph.com!goblin3!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Ilkka Virta Newsgroups: gnu.bash.bug Subject: Re: Bug on bash shell - $PWD (and consequentely prompt) not updated while renaming current folder. Date: Sat, 20 Jun 2020 18:26:45 +0300 Lines: 29 Approved: bug-bash@gnu.org Message-ID: References: <051e2fbabf3a9912e5d4248efba0f02b@goncalo.pt> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: usenet.stanford.edu 1592666822 14293 209.51.188.17 (20 Jun 2020 15:27:02 GMT) X-Complaints-To: action@cs.stanford.edu Cc: goncalo_nuno@sapo.pt To: correio@goncalo.pt, bug-bash@gnu.org Envelope-to: bug-bash@gnu.org User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 In-Reply-To: <051e2fbabf3a9912e5d4248efba0f02b@goncalo.pt> Content-Language: en-US X-SASI-RCODE: 200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; h=subject:to:cc:references:from:message-id:date:mime-version:in-reply-to:content-type:content-transfer-encoding; s=smtp; bh=KXqHmrfl2gP2GnNoiiZrj8QRhhQPq7OYuunpBN2Zq6w=; b=kAcqrk6ixRm6IU1HhVHWgqK9cMBWS/WL3auIimkdrlDYoaGDterCzpWVVDIaIUeUGW3GwZCQjiH/+vx4umcycm/HmSxw5/ZZdR7RJr+UD6kV7ywO4R0fYS6zqumCqIHyh88w6yYb8frlu9QUE9Pdak+kOYt27kZnK582TUrLm2gxGBjNWZxlWQAOMNAK6qCV542+k4x/yC6Qm2U+2oN2DI/5PPa91ZEgYNMUoGEmejL6pRx9cGNSejgpjwWE+84sGe9Ym++4lw5OvxDRChx5sXFw6M8mTkk8Hte6ow/ruGYgzhTyk/0hh3QH+AcpQocGjC6EnyEqtcdbRbuoF+YWYA== Received-SPF: neutral client-ip=157.24.2.213; envelope-from=itvirta@iki.fi; helo=smtp-in-1.cc.lut.fi X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/20 11:26:47 X-ACL-Warn: Detected OS = FreeBSD 8.x X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NEUTRAL=0.779, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <051e2fbabf3a9912e5d4248efba0f02b@goncalo.pt> Xref: csiph.com gnu.bash.bug:16416 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