Add command-exists shell helper

This commit is contained in:
2020-05-23 19:16:06 +01:00
parent ba559be4bc
commit d4d64f654e
7 changed files with 16 additions and 8 deletions

View File

@@ -10,12 +10,12 @@ install_python_global_packages () {
'yamllint'
)
if [[ "$OSTYPE" == "darwin"* ]] && (( $+commands[brew] )); then
if [[ "$OSTYPE" == "darwin"* ]] && command-exists brew; then
brew list python >/dev/null || brew install python
fi
local pipcmd="pip"
if (( $+commands[pip3] )); then; pipcmd="pip3"; fi
if command-exists pip3; then pipcmd="pip3"; fi
"$pipcmd" install --upgrade setuptools
"$pipcmd" install --upgrade "${packages[@]}"