From 7173466eeefde5473b24b8c6c2e26d3f32c3d1e5 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Tue, 8 Sep 2015 08:29:52 -0700 Subject: [PATCH] Unset CDPATH to prevent weird problems but allow suppressing this behavior in case someone is testing something that relies on CDPATH. Fixes: https://github.com/sstephenson/bats/issues/104 --- libexec/bats | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libexec/bats b/libexec/bats index 71f392f7..eb97f8df 100755 --- a/libexec/bats +++ b/libexec/bats @@ -1,5 +1,11 @@ #!/usr/bin/env bash set -e +if [ ! -z "$CDPATH" -a -z "$BATS_KEEP_CDPATH" ]; then + echo "Unsetting CDPATH to prevent problems like https://github.com/sstephenson/bats/issues/104 ..." + echo "To suppress this behavior, set BATS_KEEP_CDPATH" + echo "You may want to consider not exporting CDPATH" + unset CDPATH +fi version() { echo "Bats 0.4.0"