Created
March 14, 2018 11:44
-
-
Save geedew/3e95d98469d8a327c6b4dfe40864ca36 to your computer and use it in GitHub Desktop.
Removing a cross-platform symlink.
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
# Pulled from https://stackoverflow.com/questions/18641864/git-bash-shell-fails-to-create-symbolic-links | |
# https://stackoverflow.com/users/124119/camilo-martin | |
# Detect windows (assumes we are in 'msysgit' or similar). | |
windows() { [[ -n "$WINDIR" ]]; } | |
# Remove a link, cross-platform. | |
rmlink() { | |
if windows; then | |
# Again, Windows needs to be told if it's a file or directory. | |
if [[ -d "$1" ]]; then | |
rmdir "$1"; | |
else | |
rm "$1" | |
fi | |
else | |
rm "$1" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment