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: Chet Ramey
Subject: Re: [PATCH] Fix hang if $OLDPWD points to inaccessible directory
Date: Fri, 29 Sep 2017 10:16:06 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 9/29/17 5:12 AM, Mikulas Patocka wrote:
> 
> 
> On Thu, 28 Sep 2017, Eduardo A. Bustamante López wrote:
> 
>> On Thu, Sep 28, 2017 at 11:44:02AM +0200, Mikulas Patocka wrote:
>> [...]
>>> +++ bash/variables.c
>>> @@ -899,7 +899,7 @@ set_pwd ()
>>>       don't find OLDPWD in the environment, or it doesn't name a directory,
>>>       make a dummy invisible variable for OLDPWD, and mark it as exported. 
>>> */
>>>    temp_var = find_variable ("OLDPWD");
>>> -  if (temp_var == 0 || value_cell (temp_var) == 0 || file_isdir 
>>> (value_cell (temp_var)) == 0)
>>> +  if (temp_var == 0 || value_cell (temp_var) == 0)
>>>      {
>>>        temp_var = bind_variable ("OLDPWD", (char *)NULL, 0);
>>
>> This patch would revert the change introduced in:
>>   
>> http://git.savannah.gnu.org/cgit/bash.git/commit/?h=devel&id=e6f5e0c858b7c0839d346d7d55e56894648c5a33
> 
> This patch doesn't revert the above change. It only removes a test if 
> $OLDPWD is a directory. With this patch, if $OLDPWD points to a directory, 
> there will be no change, and if $OLDPWD points to non-directory, it will 
> not be cleared.

OLDPWD must be a directory, and while it's technically the user's
responsibility to ensure that it is, the shell should only inherit it
if it has a valid value.  (As I said back in 2015, in the same way it
inherits PWD only if it names the current directory.)

> 
>> Which was prompted by the following bug report from John Wiersba:
>>   https://lists.gnu.org/archive/html/bug-bash/2015-11/msg00115.html
>>
>> Correct me if I'm wrong, but a hanged sshfs mount will cause many more
>> issues, not only with OLDPWD.
> 
> Hung mount shouldn't cause problems unless someone is accessing it.

That's like saying a problem will only be a problem if someone makes
it a problem.

It really seems like you want bash to save you from a problem you
introduced by yanking a remote mount out from underneath your system.
It seems better to, say, specify that the automount operation is
interruptible than to change the shell for what is a rare occurrence.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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