mirror of
https://github.com/rwf2/Rocket.git
synced 2025-02-17 22:22:03 +00:00
Fallback to relative path if directory doesn't exist.
This commit is contained in:
parent
647efe15d1
commit
9cf23ae2d4
@ -5,11 +5,16 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|||||||
function relative() {
|
function relative() {
|
||||||
local full_path="${SCRIPT_DIR}/../${1}"
|
local full_path="${SCRIPT_DIR}/../${1}"
|
||||||
|
|
||||||
# Use readlink as a fallback to readpath for cross-platform compat.
|
if [ -d "${full_path}" ]; then
|
||||||
if ! command -v realpath >/dev/null 2>&1; then
|
# Use readlink as a fallback to readpath for cross-platform compat.
|
||||||
echo $(readlink -f "${full_path}")
|
if ! command -v realpath >/dev/null 2>&1; then
|
||||||
|
echo $(readlink -f "${full_path}")
|
||||||
|
else
|
||||||
|
echo $(realpath "${full_path}")
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo $(realpath "${full_path}")
|
# when the directory doesn't exist, fallback to this.
|
||||||
|
echo "${full_path}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user