From 642d6fa193a9ea7334fd4592b4d52300d07bd24b Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Wed, 1 May 2019 13:17:35 -0400 Subject: [PATCH] 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. --- minimal/do | 3 +++ redo/builder.py | 2 ++ t/shelltest.od | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/minimal/do b/minimal/do index bd78473..258a25e 100755 --- a/minimal/do +++ b/minimal/do @@ -17,6 +17,9 @@ usage: do [-d] [-x] [-v] [-c] 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="" diff --git a/redo/builder.py b/redo/builder.py index 01ada27..bebc1fa 100644 --- a/redo/builder.py +++ b/redo/builder.py @@ -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 + ' ' diff --git a/t/shelltest.od b/t/shelltest.od index a568b86..948a36c 100644 --- a/t/shelltest.od +++ b/t/shelltest.od @@ -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