Last active
November 20, 2015 09:17
-
-
Save antonfisher/bc7f79ee5c7211bc05cb to your computer and use it in GitHub Desktop.
BASH: check_directory_exits
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
## | |
# Check directory | |
# $1 {String} - path | |
# $2 {Number} - show error | |
# | |
# @returns {Number} 0 - exists / 1 - not exists | |
# | |
# Example: | |
# check_directory_exits /tmp 1; | |
# | |
function check_directory_exits { | |
if [[ -d "$1" ]]; then | |
return 0; | |
else | |
if [[ "$2" == 1 ]]; then | |
echo -e "Directory '$1' does not exist. Please try again."; | |
fi; | |
return 1; | |
fi; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment