Skip to content

Instantly share code, notes, and snippets.

@Simounet
Created February 17, 2014 14:28
Show Gist options
  • Save Simounet/9051556 to your computer and use it in GitHub Desktop.
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
#!/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