Skip to content

Instantly share code, notes, and snippets.

@pastleo
Created August 12, 2014 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pastleo/d9f2a4f6a1219d7f87bb to your computer and use it in GitHub Desktop.
Save pastleo/d9f2a4f6a1219d7f87bb to your computer and use it in GitHub Desktop.
取得絕對路徑...大致有效啦
abspath(){
local result
if [[ "$1" =~ ^(/|~).*$ ]]; then
result="$1"
else
result="$(pwd)/$1"
fi
if [[ ! "$result" =~ ^.+/$ ]]; then
result="$result/"
fi
printf $result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment