mirror of
https://github.com/sstephenson/bats.git
synced 2024-12-27 23:19:44 +01:00
Fix abs_dirname
There are no tests for this unfortunately and it is copied into two places. Ref: https://github.com/rbenv/rbenv/pull/868
This commit is contained in:
parent
03608115df
commit
87ae363144
19
install.sh
19
install.sh
|
@ -6,17 +6,22 @@ resolve_link() {
|
|||
}
|
||||
|
||||
abs_dirname() {
|
||||
local cwd="$(pwd)"
|
||||
local path="$1"
|
||||
local save_cwd="$PWD"
|
||||
local dir name
|
||||
|
||||
while [ -n "$path" ]; do
|
||||
cd "${path%/*}"
|
||||
local name="${path##*/}"
|
||||
while [[ -n "$path" ]]; do
|
||||
dir="${path%/*}"
|
||||
if [[ "$dir" != "$path" ]]; then
|
||||
cd "$dir"
|
||||
name="${path##*/}"
|
||||
else
|
||||
name="$path"
|
||||
fi
|
||||
path="$(resolve_link "$name" || true)"
|
||||
done
|
||||
|
||||
pwd
|
||||
cd "$cwd"
|
||||
echo "$PWD"
|
||||
cd "$save_cwd"
|
||||
}
|
||||
|
||||
PREFIX="$1"
|
||||
|
|
19
libexec/bats
19
libexec/bats
|
@ -31,17 +31,22 @@ resolve_link() {
|
|||
}
|
||||
|
||||
abs_dirname() {
|
||||
local cwd="$(pwd)"
|
||||
local path="$1"
|
||||
local save_cwd="$PWD"
|
||||
local dir name
|
||||
|
||||
while [ -n "$path" ]; do
|
||||
cd "${path%/*}"
|
||||
local name="${path##*/}"
|
||||
while [[ -n "$path" ]]; do
|
||||
dir="${path%/*}"
|
||||
if [[ "$dir" != "$path" ]]; then
|
||||
cd "$dir"
|
||||
name="${path##*/}"
|
||||
else
|
||||
name="$path"
|
||||
fi
|
||||
path="$(resolve_link "$name" || true)"
|
||||
done
|
||||
|
||||
pwd
|
||||
cd "$cwd"
|
||||
echo "$PWD"
|
||||
cd "$save_cwd"
|
||||
}
|
||||
|
||||
expand_path() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user