X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=bin%2Fsetup.lib.sh;h=d98f2f52e27b1bcb1a9baf6719fb2720f8f16225;hb=7a7971bd6efc4c713933abb705d165bb677344b3;hp=8ee4db00add4f2bc063da82c8e1e358a47dd24ee;hpb=a969ba2b3fc64eebf12a98e3bfc69212d832ee19;p=civicrm-core.git diff --git a/bin/setup.lib.sh b/bin/setup.lib.sh index 8ee4db00ad..d98f2f52e2 100644 --- a/bin/setup.lib.sh +++ b/bin/setup.lib.sh @@ -31,4 +31,27 @@ function mysqladmin_cmd() { function mysqldump_cmd() { _mysql_vars echo "mysqldump -u$DBUSER $PASSWDSECTION $HOSTSECTION $PORTSECTION $DBARGS" -} \ No newline at end of file +} + +## Pick the first available command. If none, then abort. +## example: COMPOSER=$(pickcmd composer composer.phar) +function pickcmd() { + for name in "$@" ; do + if which $name >> /dev/null ; then + echo $name + return + fi + done + echo "ERROR: Failed to find any of these commands: $@" + exit 1 +} + +## usage: has_commands ... +function has_commands() { + for cmd in "$@" ; do + if ! which $cmd >> /dev/null ; then + return 1 + fi + done + return 0 +}