From 97bb1fc7ba3cb49113b058a5acb9296544fb4bf2 Mon Sep 17 00:00:00 2001 From: cornfeedhobo Date: Mon, 3 Aug 2020 14:20:04 -0500 Subject: [PATCH] allow the caller to pass a custom log message when the command is not found --- lib/helpers.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/helpers.bash b/lib/helpers.bash index 2459e02b..da3abc0a 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -19,9 +19,11 @@ function _command_exists () { _about 'checks for existence of a command' _param '1: command to check' + _param '2: (optional) log message to include when command not found' _example '$ _command_exists ls && echo exists' _group 'lib' - type "$1" &> /dev/null || (_log_warning "Command $1 does not exist!" && return 1) ; + local msg="${2:-Command '$1' does not exist!}" + type "$1" &> /dev/null || (_log_warning "$msg" && return 1) ; } function _make_reload_alias() {