git-secret/vendor/bats-core/bin/bats
Josh Rabinowitz 5360384085
Import bats core (#380)
* bats-core v1.1.0 imported
* target 'install-test' removed from Makefile
* info re: bats-core import added in vendor/bats-core/README.md
2019-03-04 18:52:53 -05:00

51 lines
1022 B
Bash
Executable File

#!/usr/bin/env bash
set -e
export BATS_READLINK='true'
if command -v 'greadlink' >/dev/null; then
BATS_READLINK='greadlink'
elif command -v 'readlink' >/dev/null; then
BATS_READLINK='readlink'
fi
bats_resolve_link() {
if ! "$BATS_READLINK" "$1"; then
return 0
fi
}
bats_resolve_absolute_root_dir() {
local cwd="$PWD"
local path="$1"
local result="$2"
local target_dir
local target_name
local original_shell_options="$-"
# Resolve the parent directory, e.g. /bin => /usr/bin on CentOS (#113).
set -P
while true; do
target_dir="${path%/*}"
target_name="${path##*/}"
if [[ "$target_dir" != "$path" ]]; then
cd "$target_dir"
fi
if [[ -L "$target_name" ]]; then
path="$(bats_resolve_link "$target_name")"
else
printf -v "$result" -- '%s' "${PWD%/*}"
set +P "-$original_shell_options"
cd "$cwd"
return
fi
done
}
export BATS_ROOT
bats_resolve_absolute_root_dir "$0" 'BATS_ROOT'
exec "$BATS_ROOT/libexec/bats-core/bats" "$@"