24 lines
471 B
Bash
24 lines
471 B
Bash
#!/bin/bash
|
|
|
|
# get full absolute bath from a current or parent path
|
|
function abs-path {
|
|
local target="$1"
|
|
if [ "$target" == "." ]; then
|
|
echo "$(pwd)"
|
|
elif [ "$target" == ".." ]; then
|
|
echo "$(dirname "$(pwd)")"
|
|
else
|
|
echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
|
|
fi
|
|
}
|
|
|
|
isAbsPath() {
|
|
if [[ "${1:0:1}" == / || "${1:0:2}" == ~[/a-z] ]]
|
|
then
|
|
echo "true"
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|