Created
August 12, 2014 16:19
-
-
Save pastleo/d9f2a4f6a1219d7f87bb to your computer and use it in GitHub Desktop.
取得絕對路徑...大致有效啦
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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