1
0
mirror of https://github.com/sstephenson/bats.git synced 2024-11-17 03:32:27 +01:00

Redirecting cd stdout to /dev/null to avoid CDPATH noise

This commit is contained in:
Damien Nadé 2015-09-08 16:52:19 +02:00
parent 03608115df
commit b217a7a10c
3 changed files with 7 additions and 7 deletions

View File

@ -10,13 +10,13 @@ abs_dirname() {
local path="$1"
while [ -n "$path" ]; do
cd "${path%/*}"
cd "${path%/*}" >/dev/null
local name="${path##*/}"
path="$(resolve_link "$name" || true)"
done
pwd
cd "$cwd"
cd "$cwd" >/dev/null
}
PREFIX="$1"

View File

@ -35,19 +35,19 @@ abs_dirname() {
local path="$1"
while [ -n "$path" ]; do
cd "${path%/*}"
cd "${path%/*}" >/dev/null
local name="${path##*/}"
path="$(resolve_link "$name" || true)"
done
pwd
cd "$cwd"
cd "$cwd" >/dev/null
}
expand_path() {
{ cd "$(dirname "$1")" 2>/dev/null
{ cd "$(dirname "$1")" >/dev/null 2>&1
local dirname="$PWD"
cd "$OLDPWD"
cd "$OLDPWD" >/dev/null
echo "$dirname/$(basename "$1")"
} || echo "$1"
}

View File

@ -150,7 +150,7 @@ fixtures bats
}
@test "failing test file outside of BATS_CWD" {
cd "$TMP"
cd "$TMP" >/dev/null
run bats "$FIXTURE_ROOT/failing.bats"
[ $status -eq 1 ]
[ "${lines[2]}" = "# (in test file $FIXTURE_ROOT/failing.bats, line 4)" ]