EOF
}
+printRealPath ()
+{
+ if command -v grealpath >/dev/null
+ then
+ grealpath "${1}"
+ elif command -v realpath >/dev/null
+ then
+ realpath "${1}"
+ elif command -v greadlink >/dev/null
+ then
+ # test greadlink first as greadlink has the feature on macos
+ # but readlink only has it on linux, note that it's probably
+ # the same on bsd
+ # note: (g)readlink requires the file to be create first
+ greadlink -f "${1}"
+ elif command -v readlink >/dev/null
+ then
+ # --help and -f options are GNU readlink things
+ if readlink --help >/dev/null 2>&1
+ then
+ readlink -f "${1}"
+ else
+ if ! python -c "import os; print(os.path.realpath('${1}'))"
+ then
+ printf 'ERROR: no known way to compute real path of a file' >&2
+ return 1
+ fi
+ fi
+ fi
+}
+
+if "${mkdir_download}"
+then
+ ${MKDIR_P} "${download_dir}"
+ real_download_dir="$(printRealPath "${download_dir}")"
+fi
+
sanitizeDB () {
sed -e 's/#.*//;s/[ \t][ \t][ \t]*/\t/g;s/^[ \t]*//;s/[ \t]*$//' \
| grep -v '^$'
selected_list="$(dedupeList "${selected_list}")"
-if "${mkdir_download}"
-then
- ${MKDIR_P} "${download_dir}"
- real_download_dir="$(readlink -f "${download_dir}")"
-fi
-
if "${mkdir_install}"
then
${MKDIR_P} "${install_dir}"
- real_install_dir="$(readlink -f "${install_dir}")"
+ real_install_dir="$(printRealPath "${install_dir}")"
fi
if "${list_licenses}"