Created
February 17, 2014 14:28
-
-
Save Simounet/9051556 to your computer and use it in GitHub Desktop.
Bash script to check if there is a local command's version before the global one
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
#!/bin/bash | |
alias be='local_or_global behat' | |
alias comp='local_or_global composer /usr/local/bin/' | |
function local_or_global() { | |
if [ -f ./bin/$1 ] | |
then | |
echo "LOCAL:" | |
./bin/$1 | |
elif [ $2 ] && [ -f $2$1 ] | |
then | |
echo "CUSTOM:" | |
$2$1 | |
else | |
echo "GLOBAL:" | |
/usr/bin/$1 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment