bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Fix hang if $OLDPWD points to inaccessible directory


From: Eduardo A . Bustamante López
Subject: Re: [PATCH] Fix hang if $OLDPWD points to inaccessible directory
Date: Fri, 29 Sep 2017 06:29:16 -0500
User-agent: NeoMutt/20170609 (1.8.3)

On Fri, Sep 29, 2017 at 12:51:37AM -0700, L A Walsh wrote:
[...]
> Why does bash clear OLDPWD when a child script is started?
> 
> OLDPWD is exported and passed to any children, but bash apparently clears
> OLDPWD whenever a child script is started...
> 
> GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
> 
> Can bash be fixed to preserve the value of any OLDPWD in its initial
> environment, like it does with PWD?

Eh, 4.1? That's ~8 years old.

Check the commit I linked, there's the fix you're asking for.

> ---
> 
> I don't see a reason...
> I see a "want", but no real reason....
> 
> I'd agree it's a rare event to hit though, but when you do...
> 
> Requires console access, but changing /etc/profile to
> insert a bad OLDPWD to a known down network location might not be
> considered a trivial occurrence to someone stressed out and trying to log
> in and find out why everyone logging in is hanging...

Why would logins hang? We're talking about OLDPWD here. OLDPWD is not
set if you're not logged in.

The reported scenario is:

- You are in a network filesystem (let's call it /net/myuser)
- chdir() somewhere else, e.g. /home/myuser 
  (OLDPWD=/net/myuser, PWD=/home/myuser)
- Then you unplug your computer, or the computer that provides the
  network share.
- Then you start a new bash shell, which will hang because it'll try to
  stat($OLDPWD).

To which the solution is: unmount the network share properly.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]