Created
June 30, 2015 04:50
-
-
Save Tukki/e6a79f9bf93ad7530348 to your computer and use it in GitHub Desktop.
shell判断脚本的当前目录. bash/zsh
This file contains hidden or 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
if [ -n "$BASH" ] ; then | |
_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | |
_basepath=$(dirname "$_DIR") | |
fi | |
if [ -n "$ZSH_VERSION" ]; then | |
_DIR="$(dirname $(cd -P -- "$(dirname -- "$0")" && pwd -P))" | |
_basepath=$_DIR | |
fi | |
echo $_basepath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment