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
|
|
|
|
}
|