This repository has been archived on 2022-02-20. You can view files and clone it, but cannot push or open issues/pull-requests.
2020-11-10 14:09:08 -08:00
|
|
|
#!/bin/bash
|
2021-08-29 09:42:51 -07:00
|
|
|
|
|
|
|
# get full absolute bath from a current or parent path
|
2020-11-10 14:09:08 -08:00
|
|
|
function abs-path {
|
|
|
|
local target="$1"
|
|
|
|
if [ "$target" == "." ]; then
|
|
|
|
echo "$(pwd)"
|
2021-08-29 09:42:51 -07:00
|
|
|
elif [ "$target" == ".." ]; then
|
2020-11-10 14:09:08 -08:00
|
|
|
echo "$(dirname "$(pwd)")"
|
|
|
|
else
|
|
|
|
echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
|
|
|
|
fi
|
|
|
|
}
|
2021-08-29 09:42:51 -07:00
|
|
|
|
|
|
|
isAbsPath() {
|
|
|
|
if [[ "${1:0:1}" == / || "${1:0:2}" == ~[/a-z] ]]
|
|
|
|
then
|
|
|
|
echo "true"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|