From bdb962c9062e428a04d07b15a016eb35e41ed593 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Fri, 9 Dec 2016 00:20:51 +0100 Subject: [PATCH] Newer version upstream --- tests/shlint.sh | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/shlint.sh b/tests/shlint.sh index ee5fafd..ef8fd97 100755 --- a/tests/shlint.sh +++ b/tests/shlint.sh @@ -59,7 +59,7 @@ _shlint() for subdir in $subdirs; do [ -d "../$subdir" ] || continue for filename in $($FIND "../$subdir" -name '*.sh' | $SORT); do - $DEBUG $SHLINT "$filename" 2>&1 + _shlint_file "$filename" if [ $? -eq 0 ]; then echo "$filename:" else @@ -71,6 +71,28 @@ _shlint() return $ret } +_shlint_file() +{ + $DEBUG $SHLINT "$filename" 2>&1 || return 2 + #try to detect invalid use of return + #XXX this test is not accurate (therefore a warning) + warn=0 + while read line; do + case "$line" in + *return*) + warn=1 + ;; + *) + warn=0 + ;; + esac + done < "$filename" + if [ $warn -ne 0 ]; then + _warning "$filename: return instead of exit in the global scope" + fi + return 0 +} + #debug _debug() @@ -92,6 +114,14 @@ _usage() } +#warning +_warning() +{ + echo "$PROGNAME: $@" 1>&2 + return 2 +} + + #main clean=0 while getopts "cP:" name; do