mirror of
https://github.com/sobolevn/git-secret
synced 2024-11-08 19:10:31 +00:00
5360384085
* bats-core v1.1.0 imported * target 'install-test' removed from Makefile * info re: bats-core import added in vendor/bats-core/README.md
51 lines
1022 B
Bash
Executable File
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" "$@"
|