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: Mikulas Patocka
Subject: Re: [PATCH] Fix hang if $OLDPWD points to inaccessible directory
Date: Tue, 3 Oct 2017 22:29:08 +0200 (CEST)
User-agent: Alpine 2.02 (DEB 1266 2009-07-14)


On Tue, 3 Oct 2017, Chet Ramey wrote:

> On 10/3/17 4:14 PM, Mikulas Patocka wrote:
> > 
> > 
> > On Sun, 1 Oct 2017, Chet Ramey wrote:
> > 
> >> On 9/30/17 4:20 AM, Mikulas Patocka wrote:
> >>
> >>> Is there some reason why do we need to check if $OLDPWD is a real 
> >>> directory? dash and ksh accept the $OLDPWD variable, but don't poke it 
> >>> with the stat syscall. zsh clears $OLDPWD.
> >>
> >> It makes no sense to inherit it if it doesn't name a directory (or
> >> "pathname" in the Posix standard), other than the sort of lazy evaluation
> >> that will prevent your particular problem.
> > 
> > Does something bad happen if we inherit $OLDPWD that points to a 
> > non-existing directory? Will some script malfunction because of it?
> 
> `cd -' will fail, of course. That's where $OLDPWD gets used. And who
> knows whether some script will fail? It's impossible to say.

If $OLDPWD points to a non-existing directory, 'cd -' will fail.
But if we clear $OLDPWD, 'cd -' will fail too (with just different message).

Mikulas



reply via email to

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