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

fixup! Fix abs_dirname

This commit is contained in:
Daniel Hahler 2018-09-19 09:41:34 +02:00
parent 87ae363144
commit ff3b8d0115
2 changed files with 14 additions and 16 deletions

View File

@ -8,18 +8,17 @@ resolve_link() {
abs_dirname() { abs_dirname() {
local path="$1" local path="$1"
local save_cwd="$PWD" local save_cwd="$PWD"
local dir name local cd_path name
while [[ -n "$path" ]]; do while [ -n "$path" ]; do
dir="${path%/*}" cd_path="${path%/*}"
if [[ "$dir" != "$path" ]]; then if [[ "$cd_path" != "$path" ]]; then
cd "$dir" cd "$cd_path"
name="${path##*/}"
else
name="$path"
fi fi
name="${path##*/}"
path="$(resolve_link "$name" || true)" path="$(resolve_link "$name" || true)"
done done
echo "$PWD" echo "$PWD"
cd "$save_cwd" cd "$save_cwd"
} }

View File

@ -33,18 +33,17 @@ resolve_link() {
abs_dirname() { abs_dirname() {
local path="$1" local path="$1"
local save_cwd="$PWD" local save_cwd="$PWD"
local dir name local cd_path name
while [[ -n "$path" ]]; do while [ -n "$path" ]; do
dir="${path%/*}" cd_path="${path%/*}"
if [[ "$dir" != "$path" ]]; then if [[ "$cd_path" != "$path" ]]; then
cd "$dir" cd "$cd_path"
name="${path##*/}"
else
name="$path"
fi fi
name="${path##*/}"
path="$(resolve_link "$name" || true)" path="$(resolve_link "$name" || true)"
done done
echo "$PWD" echo "$PWD"
cd "$save_cwd" cd "$save_cwd"
} }