mirror of
https://github.com/octoleo/hosts.git
synced 2024-11-24 13:47:35 +00:00
Improve realpath
/ readlink
handling.
This commit is contained in:
parent
39a182b47e
commit
245188025a
14
hosts
14
hosts
@ -902,8 +902,20 @@ completions() {
|
||||
_download=1
|
||||
fi
|
||||
|
||||
local _my_path="${0}"
|
||||
|
||||
if [[ -L "${_my_path}" ]]
|
||||
then
|
||||
if hash "realpath" 2>/dev/null
|
||||
then
|
||||
_my_path="$(realpath "${_my_path}")"
|
||||
else
|
||||
_my_path="$(readlink "${_my_path}")"
|
||||
fi
|
||||
fi
|
||||
|
||||
local _my_dir=
|
||||
_my_dir="$(cd "$(dirname "$(realpath "$0")")"; pwd)"
|
||||
_my_dir="$(cd "$(dirname "${_my_path}")"; pwd)"
|
||||
if [[ -z "${_my_dir}" ]] || [[ ! -d "${_my_dir}" ]]
|
||||
then
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user