From: Banana Date: Sat, 21 Dec 2019 16:16:53 +0000 (+0100) Subject: detect if a command is available X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=84a2c5c563de10a4929a7bf64babbfda2e6c2303;p=klimbim.git detect if a command is available --- diff --git a/bash/detect-if-installed.sh b/bash/detect-if-installed.sh new file mode 100644 index 0000000..21f8ef3 --- /dev/null +++ b/bash/detect-if-installed.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Simple example how to detect if a command is available +# otherwise print message and exit + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE +# +# You should have received a copy of the +# COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 +# along with this program. If not, see http://www.sun.com/cddl/cddl.html + +# 2019 https://www.bananas-playground.net + +# In this example we need curl to be iinstalled. +# If not print message and exit. +command -v curl >/dev/null 2>&1 || { echo >&2 "I require curl (https://curl.haxx.se/) but it's not installed. Aborting."; exit 1; }