From 5f79f0f9f32495b7623e6d82047901b5212d0c14 Mon Sep 17 00:00:00 2001 From: Ryan Loudfoot Date: Sun, 3 Nov 2013 18:11:48 -0500 Subject: [PATCH] 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 --- check_domain | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_domain b/check_domain index 063f9a8..6c92335 100755 --- a/check_domain +++ b/check_domain @@ -50,13 +50,13 @@ warning=30 #MONTH=("jan" "feb" "mar" "apr" "may" "jun" "jul" "aug" "sep" "oct" "nov" "dec") # 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 echo >&2 "$PROGRAM: Could not parse arguments" echo "Usage: $PROGRAM -h | -d [-c ] [-w ]" exit 1 fi -set -- $args +eval "set -- $args" die() { local rc=$1