More shellcheck fixes.

Change-Id: Iee9e464b3935d4c8a09fa9954f73496eae33f30f
Reviewed-on: https://code.wireshark.org/review/28092
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2018-06-07 15:03:48 -07:00
parent 0e3901d82f
commit bfb7028ba9
4 changed files with 23 additions and 16 deletions

View File

@ -3019,9 +3019,12 @@ if(SHELLCHECK_EXECUTABLE)
tools/compress-pngs.sh
tools/git-export-release.sh
tools/fuzz-test.sh
tools/gen-bugnote
tools/pre-commit
tools/randpkt-test.sh
tools/release-update-debian-soversions.sh
tools/test-captures.sh
tools/update-tx
tools/valgrind-wireshark.sh
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)

View File

@ -10,7 +10,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later
#
bz_url_pfx="https://bugs.wireshark.org/bugzilla/show_bug.cgi?id="
bz_url_pfx="https://bugs.wireshark.org/bugzilla/show_bug.cgi"
bug_id="$1"
recode_cmd="cat"
@ -33,12 +33,12 @@ case "$OSTYPE" in
esac
if [ -z "$bug_id" ] ; then
echo "Usage: " `basename $0` " <bug id>"
echo "Usage: $( basename "$0" ) <bug id>"
exit 1
fi
bug_title=$(
curl -s -o - "https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=$bug_id" \
curl -s -o - "${bz_url_pfx}?id=$bug_id" \
| grep -i '<title>' \
| sed \
-e 's/{/\\{/' \
@ -48,7 +48,7 @@ bug_title=$(
-e 's/\\/{backslash}/' \
)
echo -e "* $bug_title (wsbuglink:$bug_id[])\n" \
echo -e "* $bug_title (wsbuglink:${bug_id}[])\\n" \
| $recode_cmd \
| $clipboard_cmd

View File

@ -13,7 +13,7 @@
# tools/pre-commit HEAD~
#
# Relative paths are also supported. For instance, if you are in epan/, then you
# could invoke `../tools/pre-commit HEAD` to check for changes to staged files.
# could invoke `../tools/pre-commit HEAD` to check for changes to staged files.
#
# From
# http://mark-story.com/posts/view/using-git-commit-hooks-to-prevent-stupid-mistakes
@ -22,7 +22,7 @@
# If the commit identifier is not given, use HEAD instead.
COMMIT_ID="${1:-HEAD}"
UNAME=`uname -a`
UNAME=$( uname -a )
case "$UNAME" in
*\ Msys)
@ -40,7 +40,10 @@ hook_script=${GIT_DIR:-.git}/hooks/pre-commit
# Always start in the root directory of the source tree, this allows for
# invocations via relative paths (such as ../tools/pre-commit):
cd "$(git rev-parse --show-toplevel)"
if ! cd "$(git rev-parse --show-toplevel)" ; then
echo "Can't change to the top-level source directory."
exit 1
fi
# Check for newer (actually, different) versions of the pre-commit script
# (but only if invoked as hook, i.e. the commit ID is not given as argument).
@ -52,15 +55,15 @@ fi
exit_status=0
COMMIT_FILES=`git diff-index --cached --name-status ${COMMIT_ID} | grep -v "^D" | cut -f2 | grep "\.[ch]$"`
DIAMETER_FILES=`git diff-index --cached --name-status ${COMMIT_ID} | grep -v "^D" | cut -f2 | grep diameter/`
COMMIT_FILES=$( git diff-index --cached --name-status "${COMMIT_ID}" | grep -v "^D" | cut -f2 | grep "\\.[ch]$" )
DIAMETER_FILES=$( git diff-index --cached --name-status "${COMMIT_ID}" | grep -v "^D" | cut -f2 | grep diameter/ )
# Path to filter script in the tools directory
filter_script=${PWD}/tools/pre-commit-ignore.py
filter_conf=${PWD}/tools/pre-commit-ignore.conf
if [ -f "$filter_script" ] && [ -f "$filter_conf" ]; then
CHECK_FILES=`echo "$COMMIT_FILES" | "$PYBIN" "$filter_script" "$filter_conf"` || exit
CHECK_FILES=$( echo "$COMMIT_FILES" | "$PYBIN" "$filter_script" "$filter_conf" ) || exit
else
CHECK_FILES="$COMMIT_FILES"
fi
@ -74,24 +77,24 @@ fi
#
# The Single UNIX Specification says that tr supports \r; most if not
# all modern UN*Xes should support it.
CHECK_FILES=`echo "$CHECK_FILES" | tr -d '\r'`
CHECK_FILES=$( echo "$CHECK_FILES" | tr -d '\r' )
for FILE in $CHECK_FILES; do
#Check if checkhf is good
./tools/checkhf.pl $FILE || exit_status=1
./tools/checkhf.pl "$FILE" || exit_status=1
#Check if checkAPIs is good
./tools/checkAPIs.pl -p $FILE || exit_status=1
./tools/checkAPIs.pl -p "$FILE" || exit_status=1
#Check if fix-encoding-args is good
./tools/fix-encoding-args.pl $FILE || exit_status=1
./tools/fix-encoding-args.pl "$FILE" || exit_status=1
#Check if checkfiltername is good
./tools/checkfiltername.pl $FILE || exit_status=1
./tools/checkfiltername.pl "$FILE" || exit_status=1
# If there are whitespace errors, print the offending file names and fail. (from git pre-commit.sample)
git diff-index --check --cached ${COMMIT_ID} $FILE || exit_status=1
git diff-index --check --cached "${COMMIT_ID}" "$FILE" || exit_status=1
done

View File

@ -7,6 +7,7 @@ NO_PUSH="False"
while getopts "n" OPTCHAR ; do
case $OPTCHAR in
n) NO_PUSH="True" ;;
*) printf "Unknown option: %s\\n" "$OPTARG"
esac
done
shift $((OPTIND - 1))