1
0
mirror of https://github.com/sstephenson/bats.git synced 2024-11-17 03:32:27 +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() {
local path="$1"
local save_cwd="$PWD"
local dir name
local cd_path name
while [[ -n "$path" ]]; do
dir="${path%/*}"
if [[ "$dir" != "$path" ]]; then
cd "$dir"
name="${path##*/}"
else
name="$path"
while [ -n "$path" ]; do
cd_path="${path%/*}"
if [[ "$cd_path" != "$path" ]]; then
cd "$cd_path"
fi
name="${path##*/}"
path="$(resolve_link "$name" || true)"
done
echo "$PWD"
cd "$save_cwd"
}

View File

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