Unset CDPATH if it is set.

Apparently on some (probably buggy) platforms, when CDPATH is set, the
'cd' command will always print text to stdout.  This caused fail 122
and 123 in shelltest.od.

CDPATH is an interactive-mode option, so let's clear it when running
scripts.
This commit is contained in:
Avery Pennarun 2019-05-01 13:17:35 -04:00
commit 642d6fa193
3 changed files with 6 additions and 1 deletions

View file

@ -17,6 +17,9 @@ usage: do [-d] [-x] [-v] [-c] <targets...>
It will never rebuild a target it has already built, unless you use -c.
"
# CDPATH apparently causes unexpected 'cd' output on some platforms.
unset CDPATH
# By default, no output coloring.
green=""
bold=""

View file

@ -309,6 +309,8 @@ class _BuildJob(object):
# now.
assert state.is_flushed()
newp = os.path.realpath(dodir)
# CDPATH apparently caused unexpected 'cd' output on some platforms.
os.unsetenv('CDPATH')
os.environ['REDO_PWD'] = state.relpath(newp, env.v.STARTDIR)
os.environ['REDO_TARGET'] = basename + ext
os.environ['REDO_DEPTH'] = env.v.DEPTH + ' '

View file

@ -513,7 +513,7 @@ x=$(printf "a%-5sc" "b")
[ "$x" = "ab c" ] || warn 119
# Make sure cd supports -L and -P options properly
rm -f shlink
rm -f shlink ../shlink
ln -s . shlink
(quiet_stderr cd -L shlink/shlink/shlink/../shlink) || fail 120
(quiet_stderr cd -P shlink/shlink/shlink/../shlink) && fail 121