Updated as per Vidar from shellcheck.net.
Email received from Vidar: Hi, On line 53 in the script, getopt is used with -u: -u, --unquoted Do not quote the output. Note that whitespace and special (shell-dependent) characters can cause havoc in this mode (like they do with other getopt(1) implementations). This havoc is basically what Shellcheck is warning about. Unfortunately it's not simply a matter of quoting the variable, since the underlying problem is the way getopt is used. Instead of -u, you can use -s bash, and then eval instead of word split: args=$(getopt -o hd:w:c:P: --long help,domain:,warning:,critical:,path: -s bash -n "$PROGRAM" -- "$@") ... eval "set -- $args" This way, no havoc is caused, and no shellcheck errors are reported. Regards, Vidar
This commit is contained in:
parent
c6471330d6
commit
5f79f0f9f3
@ -50,13 +50,13 @@ warning=30
|
|||||||
#MONTH=("jan" "feb" "mar" "apr" "may" "jun" "jul" "aug" "sep" "oct" "nov" "dec")
|
#MONTH=("jan" "feb" "mar" "apr" "may" "jun" "jul" "aug" "sep" "oct" "nov" "dec")
|
||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
args=$(getopt -o hd:w:c:P: --long help,domain:,warning:,critical:,path: -u -n "$PROGRAM" -- "$@")
|
args=$(getopt -o hd:w:c:P: --long help,domain:,warning:,critical:,path: -s bash -n "$PROGRAM" -- "$@")
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
echo >&2 "$PROGRAM: Could not parse arguments"
|
echo >&2 "$PROGRAM: Could not parse arguments"
|
||||||
echo "Usage: $PROGRAM -h | -d <domain> [-c <critical>] [-w <warning>]"
|
echo "Usage: $PROGRAM -h | -d <domain> [-c <critical>] [-w <warning>]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
set -- $args
|
eval "set -- $args"
|
||||||
|
|
||||||
die() {
|
die() {
|
||||||
local rc=$1
|
local rc=$1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user