[Top][All Lists]

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

OLDPWD unset when bash starts

From: John Wiersba
Subject: OLDPWD unset when bash starts
Date: Wed, 18 Nov 2015 19:44:28 +0000 (UTC)

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:

$ cd /etc
$ cd
$ perl -e 'print "<$ENV{OLDPWD}>\n"'
$ ksh  -c 'echo "<$OLDPWD>"'
$ bash -c 'echo "<$OLDPWD>"'

$ uname -a
Linux myserver 2.6.32-504.8.1.el6.x86_64 #1 SMP Fri Dec 19 12:09:25 EST 2014 
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.5 (Santiago)
$ bash --version | head -1

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?

-- John Wiersba

reply via email to

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