sane-which: handle relative symlinks
This commit is contained in:
@@ -6,12 +6,15 @@
|
|||||||
cur="$1"
|
cur="$1"
|
||||||
next="$(which "$cur")"
|
next="$(which "$cur")"
|
||||||
|
|
||||||
|
getExists() {
|
||||||
|
[ -e "$1" ] && echo "$1"
|
||||||
|
}
|
||||||
|
|
||||||
getSymlinked() {
|
getSymlinked() {
|
||||||
# test if $cur is a symlink
|
# test if $cur is a symlink
|
||||||
# TODO: handle relative symlinks too!
|
|
||||||
local next_
|
local next_
|
||||||
next_="$(readlink "$cur")"
|
next_="$(readlink "$cur")"
|
||||||
[ "$?" -eq 0 ] && echo "$next_"
|
[ "$?" -eq 0 ] && (getExists "$next_" || getExists "$(dirname "$cur")/$next_" || echo "$next_")
|
||||||
}
|
}
|
||||||
|
|
||||||
getWrapped() {
|
getWrapped() {
|
||||||
|
Reference in New Issue
Block a user