Skip to content

Commit a40d732

Browse files
committed
Fixed issues found by shellcheck
1 parent e702afa commit a40d732

File tree

7 files changed

+42
-42
lines changed

7 files changed

+42
-42
lines changed

adc.sh

+20-21
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ SCRIPTNAME=$0
1616
# register namespace_command help
1717
function register {
1818
GLOBAL_COMMANDS="$GLOBAL_COMMANDS $1"
19-
GLOBAL_HELP="$GLOBAL_HELP\n$@"
19+
GLOBAL_HELP="$GLOBAL_HELP\n$*"
2020
}
2121
COLOR_WARNING="\033[0;33m"
2222
COLOR_INFO="\033[0;32m"
@@ -25,27 +25,27 @@ COLOR_DEBUG="\033[0;35m"
2525
COLOR_RESET="\033[0m"
2626
function debug {
2727
if [ "${CONFIG_OUTPUT_VERBOSITY/debug}" != "$CONFIG_OUTPUT_VERBOSITY" ]; then
28-
echo -e "${COLOR_DEBUG}DEBUG: $@${COLOR_RESET}"
28+
echo -e "${COLOR_DEBUG}DEBUG: $*${COLOR_RESET}"
2929
fi
3030
}
3131
function error {
3232
if [ "${CONFIG_OUTPUT_VERBOSITY/error}" != "$CONFIG_OUTPUT_VERBOSITY" ]; then
33-
echo -e "${COLOR_ERROR}ERROR: $@${COLOR_RESET}"
33+
echo -e "${COLOR_ERROR}ERROR: $*${COLOR_RESET}"
3434
fi
3535
}
3636
function warning {
3737
if [ "${CONFIG_OUTPUT_VERBOSITY/warning}" != "$CONFIG_OUTPUT_VERBOSITY" ]; then
38-
echo -e "${COLOR_WARNING}WARNING: $@${COLOR_RESET}"
38+
echo -e "${COLOR_WARNING}WARNING: $*${COLOR_RESET}"
3939
fi
4040
}
4141
function info {
4242
if [ "${CONFIG_OUTPUT_VERBOSITY/info}" != "$CONFIG_OUTPUT_VERBOSITY" ]; then
43-
echo -e "${COLOR_INFO}INFO: $@${COLOR_RESET}"
43+
echo -e "${COLOR_INFO}INFO: $*${COLOR_RESET}"
4444
fi
4545
}
4646
function output {
4747
if [ "${CONFIG_OUTPUT_VERBOSITY}" != "" ]; then
48-
echo -e "$@"
48+
echo -e "$*"
4949
fi
5050
}
5151
function httpClient {
@@ -113,7 +113,8 @@ function _help {
113113
COMMAND_RESULT="Usage: $SCRIPTNAME <namespace> <command>\n"
114114
COMMAND_RESULT="${COMMAND_RESULT}\nTo execute a action, provide a namespace and a command, e.g. \"dbmon list\" to list all database collectors.\nFinally the following commands in the global namespace can be called directly:\n"
115115
local NAMESPACE=""
116-
local SORTED=`echo -en "$GLOBAL_HELP" | sort`
116+
local SORTED
117+
SORTED=`echo -en "$GLOBAL_HELP" | sort`
117118
OLD_IFS=$IFS
118119
IFS=$'\n'
119120
for LINE in $SORTED; do
@@ -128,7 +129,7 @@ function _help {
128129
done
129130
IFS=$OLD_IFS
130131
}
131-
register _help Display the global usage information
132+
register _help Display the global usage information
132133
CONTROLLER_LOGIN_STATUS=0
133134
function controller_login {
134135
debug "Login at $CONFIG_CONTROLLER_HOST with $CONFIG_CONTROLLER_CREDENTIALS"
@@ -159,11 +160,9 @@ function controller_call {
159160
;;
160161
esac
161162
done
162-
163163
shiftOptInd
164164
shift $SHIFTS
165-
ENDPOINT=$@
166-
165+
ENDPOINT=$*
167166
controller_login
168167
# Debug the COMMAND_RESULT from controller_login
169168
debug $COMMAND_RESULT
@@ -179,7 +178,7 @@ function controller_call {
179178
COMMAND_RESULT="Controller Login Error! Please check hostname and credentials"
180179
fi
181180
}
182-
register controller_call Send a custom HTTP call to a controller
181+
register controller_call Send a custom HTTP call to a controller
183182
function dbmon_create {
184183
echo "Stub"
185184
}
@@ -202,20 +201,20 @@ function timerange_create {
202201
DURATION_IN_MINUTES=${OPTARG}
203202
TYPE="BEFORE_NOW"
204203
;;
205-
esac
204+
esac
206205
done;
207206
shiftOptInd
208207
shift $SHIFTS
209-
TIMERANGE_NAME=$@
208+
TIMERANGE_NAME=$*
210209
controller_call -X POST -d "{\"name\":\"$TIMERANGE_NAME\",\"timeRange\":{\"type\":\"$TYPE\",\"durationInMinutes\":$DURATION_IN_MINUTES,\"startTime\":$START_TIME,\"endTime\":$END_TIME}}" /controller/restui/user/createCustomRange
211210
}
212-
register timerange_create Create a custom time range
211+
register timerange_create Create a custom time range
213212
function timerange_list {
214213
controller_call -X GET /controller/restui/user/getAllCustomTimeRanges
215214
}
216215
register timerange_list List all custom timeranges available on the controller
217216
function timerange_delete {
218-
local TIMERANGE_ID=$@
217+
local TIMERANGE_ID=$*
219218
if [[ $TIMERANGE_ID =~ ^[0-9]+$ ]]; then
220219
controller_call -X POST -d "$TIMERANGE_ID" /controller/restui/user/deleteCustomRange
221220
else
@@ -279,7 +278,7 @@ do
279278
D)
280279
CONFIG_OUTPUT_VERBOSITY=${OPTARG}
281280
debug "Set CONFIG_OUTPUT_VERBOSITY=${CONFIG_OUTPUT_VERBOSITY}"
282-
esac
281+
esac
283282
done
284283
shiftOptInd
285284
shift $SHIFTS
@@ -295,17 +294,17 @@ if [ "${GLOBAL_COMMANDS/${NAMESPACE}_}" != "$GLOBAL_COMMANDS" ] ; then
295294
COMMAND=$2
296295
if [ "$COMMAND" == "" ] ; then
297296
_help
298-
fi
297+
fi
299298
if [ "${GLOBAL_COMMANDS/${NAMESPACE}_${COMMAND}}" != "$GLOBAL_COMMANDS" ] ; then
300299
debug "${NAMESPACE}_${COMMAND} is a valid command"
301300
shift 2
302-
${NAMESPACE}_${COMMAND} $@
301+
${NAMESPACE}_${COMMAND} "$@"
303302
fi
304303
# Check if this is a global command
305304
elif [ "${GLOBAL_COMMANDS/_${NAMESPACE}}" != "$GLOBAL_COMMANDS" ] ; then
306305
debug "_${NAMESPACE} found as global command"
307-
shift 1
308-
_${NAMESPACE} $@
306+
shift 1
307+
_${NAMESPACE} "$@"
309308
fi
310309
if [ "$COMMAND_RESULT" != "" ]; then
311310
output $COMMAND_RESULT

commands/controller/call.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ function controller_call {
1414
;;
1515
esac
1616
done
17-
17+
1818
shiftOptInd
1919
shift $SHIFTS
2020

21-
ENDPOINT=$@
22-
21+
ENDPOINT=$*
22+
2323
controller_login
2424
# Debug the COMMAND_RESULT from controller_login
2525
debug $COMMAND_RESULT
@@ -36,4 +36,4 @@ function controller_call {
3636
fi
3737
}
3838

39-
register controller_call Send a custom HTTP call to a controller
39+
register controller_call Send a custom HTTP call to a controller

commands/help.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ function _help {
44
COMMAND_RESULT="Usage: $SCRIPTNAME <namespace> <command>\n"
55
COMMAND_RESULT="${COMMAND_RESULT}\nTo execute a action, provide a namespace and a command, e.g. \"dbmon list\" to list all database collectors.\nFinally the following commands in the global namespace can be called directly:\n"
66
local NAMESPACE=""
7-
local SORTED=`echo -en "$GLOBAL_HELP" | sort`
7+
local SORTED
8+
SORTED=`echo -en "$GLOBAL_HELP" | sort`
89
OLD_IFS=$IFS
910
IFS=$'\n'
1011
for LINE in $SORTED; do
@@ -20,4 +21,4 @@ function _help {
2021
IFS=$OLD_IFS
2122
}
2223

23-
register _help Display the global usage information
24+
register _help Display the global usage information

commands/timerange/create.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ function timerange_create {
1818
DURATION_IN_MINUTES=${OPTARG}
1919
TYPE="BEFORE_NOW"
2020
;;
21-
esac
21+
esac
2222
done;
2323
shiftOptInd
2424
shift $SHIFTS
25-
TIMERANGE_NAME=$@
25+
TIMERANGE_NAME=$*
2626
controller_call -X POST -d "{\"name\":\"$TIMERANGE_NAME\",\"timeRange\":{\"type\":\"$TYPE\",\"durationInMinutes\":$DURATION_IN_MINUTES,\"startTime\":$START_TIME,\"endTime\":$END_TIME}}" /controller/restui/user/createCustomRange
2727
}
2828

29-
register timerange_create Create a custom time range
29+
register timerange_create Create a custom time range

commands/timerange/delete.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
function timerange_delete {
4-
local TIMERANGE_ID=$@
4+
local TIMERANGE_ID=$*
55
if [[ $TIMERANGE_ID =~ ^[0-9]+$ ]]; then
66
controller_call -X POST -d "$TIMERANGE_ID" /controller/restui/user/deleteCustomRange
77
else

helpers/output.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,30 @@ COLOR_RESET="\033[0m"
88

99
function debug {
1010
if [ "${CONFIG_OUTPUT_VERBOSITY/debug}" != "$CONFIG_OUTPUT_VERBOSITY" ]; then
11-
echo -e "${COLOR_DEBUG}DEBUG: $@${COLOR_RESET}"
11+
echo -e "${COLOR_DEBUG}DEBUG: $*${COLOR_RESET}"
1212
fi
1313
}
1414

1515
function error {
1616
if [ "${CONFIG_OUTPUT_VERBOSITY/error}" != "$CONFIG_OUTPUT_VERBOSITY" ]; then
17-
echo -e "${COLOR_ERROR}ERROR: $@${COLOR_RESET}"
17+
echo -e "${COLOR_ERROR}ERROR: $*${COLOR_RESET}"
1818
fi
1919
}
2020

2121
function warning {
2222
if [ "${CONFIG_OUTPUT_VERBOSITY/warning}" != "$CONFIG_OUTPUT_VERBOSITY" ]; then
23-
echo -e "${COLOR_WARNING}WARNING: $@${COLOR_RESET}"
23+
echo -e "${COLOR_WARNING}WARNING: $*${COLOR_RESET}"
2424
fi
2525
}
2626

2727
function info {
2828
if [ "${CONFIG_OUTPUT_VERBOSITY/info}" != "$CONFIG_OUTPUT_VERBOSITY" ]; then
29-
echo -e "${COLOR_INFO}INFO: $@${COLOR_RESET}"
29+
echo -e "${COLOR_INFO}INFO: $*${COLOR_RESET}"
3030
fi
3131
}
3232

3333
function output {
3434
if [ "${CONFIG_OUTPUT_VERBOSITY}" != "" ]; then
35-
echo -e "$@"
35+
echo -e "$*"
3636
fi
3737
}

main.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ SCRIPTNAME=$0
2121
# register namespace_command help
2222
function register {
2323
GLOBAL_COMMANDS="$GLOBAL_COMMANDS $1"
24-
GLOBAL_HELP="$GLOBAL_HELP\n$@"
24+
GLOBAL_HELP="$GLOBAL_HELP\n$*"
2525
}
2626

2727
source ./helpers/output.sh
@@ -81,7 +81,7 @@ do
8181
D)
8282
CONFIG_OUTPUT_VERBOSITY=${OPTARG}
8383
debug "Set CONFIG_OUTPUT_VERBOSITY=${CONFIG_OUTPUT_VERBOSITY}"
84-
esac
84+
esac
8585
done
8686

8787
shiftOptInd
@@ -102,17 +102,17 @@ if [ "${GLOBAL_COMMANDS/${NAMESPACE}_}" != "$GLOBAL_COMMANDS" ] ; then
102102
COMMAND=$2
103103
if [ "$COMMAND" == "" ] ; then
104104
_help
105-
fi
105+
fi
106106
if [ "${GLOBAL_COMMANDS/${NAMESPACE}_${COMMAND}}" != "$GLOBAL_COMMANDS" ] ; then
107107
debug "${NAMESPACE}_${COMMAND} is a valid command"
108108
shift 2
109-
${NAMESPACE}_${COMMAND} $@
109+
${NAMESPACE}_${COMMAND} "$@"
110110
fi
111111
# Check if this is a global command
112112
elif [ "${GLOBAL_COMMANDS/_${NAMESPACE}}" != "$GLOBAL_COMMANDS" ] ; then
113113
debug "_${NAMESPACE} found as global command"
114-
shift 1
115-
_${NAMESPACE} $@
114+
shift 1
115+
_${NAMESPACE} "$@"
116116
fi
117117

118118
if [ "$COMMAND_RESULT" != "" ]; then

0 commit comments

Comments
 (0)