Skip to content

Commit cb18707

Browse files
committed
Add command installed check
1 parent d223a5f commit cb18707

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#-----------------------------------------------------------------------
2+
#
3+
# Basescript function
4+
#
5+
# The basescript functions were designed to work as abstract function,
6+
# so it could be used in many different contexts executing specific job
7+
# always remembering Unix concept DOTADIW - "Do One Thing And Do It Well"
8+
#
9+
# Developed by
10+
# Evert Ramos <evert.ramos@gmail.com>
11+
#
12+
# Copyright Evert Ramos
13+
#
14+
#-----------------------------------------------------------------------
15+
#
16+
# Be careful when editing this file, it is part of a bigger script!
17+
#
18+
# Basescript - https://github.com/evertramos/basescript
19+
#
20+
#-----------------------------------------------------------------------
21+
22+
#-----------------------------------------------------------------------
23+
# This function has one main objective:
24+
# 1. Check if a command is installed
25+
#
26+
# You must/might inform the parameters below:
27+
# 1. Command name
28+
#
29+
#-----------------------------------------------------------------------
30+
31+
system_check_command_installed()
32+
{
33+
local LOCAL_COMMAND
34+
35+
LOCAL_COMMAND=${1:-null}
36+
37+
[[ $LOCAL_COMMAND == "" ]] && echoerror "You must inform the COMMAND NAME to the function: '${FUNCNAME[0]}'"
38+
39+
[[ "$DEBUG" == true ]] && echo "Checking if command '$LOCAL_COMMAND' is installed."
40+
41+
if [[ ! -x "$(command -v "$LOCAL_COMMAND")" ]]; then
42+
COMMAND_IS_INSTALLED=true
43+
else
44+
COMMAND_IS_INSTALLED=false
45+
fi
46+
}
47+

system/system-safe-delete-folder.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)