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"' </etc> $ ksh -c 'echo "<$OLDPWD>"' </etc> $ 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? Thanks! -- John Wiersba