Skip to content

Commit b9ef209

Browse files
infrastationfxlb
authored andcommitted
Extend "make shellcheck" onto mkdep too. [skip appveyor]
For shell trap purposes, "1 2 3 13 15" is the same as "HUP INT QUIT PIPE TERM" in AIX, FreeBSD, Hurd, illumos, Linux, macOS, NetBSD, OpenBSD and Solaris. However, in Haiku SIGPIPE is 7 and 13 is SIGTSTP. Address all warnings from shellcheck 0.9.0: mkdep:66:11: note: Double quote to prevent globbing and word splitting. [SC2086] mkdep:73:34: warning: Trapping signals by number is not well defined. Prefer signal names. [SC2172] mkdep:75:4: note: Double quote to prevent globbing and word splitting. [SC2086] mkdep:75:10: note: Double quote to prevent globbing and word splitting. [SC2086] mkdep:77:41: note: Double quote to prevent globbing and word splitting. [SC2086] mkdep:77:49: note: Double quote to prevent globbing and word splitting. [SC2086] mkdep:79:17: note: Double quote to prevent globbing and word splitting. [SC2086] mkdep:97:16: warning: Use "$@" (with quotes) to prevent whitespace problems. [SC2048] mkdep:103:5: note: Double quote to prevent globbing and word splitting. [SC2086] mkdep:103:23: note: Double quote to prevent globbing and word splitting. [SC2086] mkdep:103:30: note: Double quote to prevent globbing and word splitting. [SC2086] mkdep:106:11: note: Double quote to prevent globbing and word splitting. [SC2086] mkdep:108:17: note: Double quote to prevent globbing and word splitting. [SC2086] mkdep:114:4: note: Double quote to prevent globbing and word splitting. [SC2086] mkdep:114:9: note: Double quote to prevent globbing and word splitting. [SC2086] mkdep:115:7: note: Double quote to prevent globbing and word splitting. [SC2086] mkdep:115:19: note: Double quote to prevent globbing and word splitting. [SC2086] (cherry picked from commit 983d432)
1 parent 57b9d78 commit b9ef209

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,4 +578,4 @@ depend:
578578
@$(MKDEP) -c $(CC) -m "$(DEPENDENCY_CFLAG)" -s "$(srcdir)" $(DEFS) $(INCLS) $(SRC) $(LIBNETDISSECT_SRC)
579579

580580
shellcheck:
581-
shellcheck -f gcc -e SC2006 autogen.sh build.sh build_matrix.sh build_common.sh .ci-coverity-scan-build.sh
581+
shellcheck -f gcc -e SC2006 autogen.sh build.sh build_matrix.sh build_common.sh mkdep .ci-coverity-scan-build.sh

mkdep

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,20 @@ if [ $# = 0 ] ; then
6363
exit 1
6464
fi
6565

66-
if [ ! -w $MAKE ]; then
66+
if [ ! -w "$MAKE" ]; then
6767
echo "mkdep: no writeable file \"$MAKE\""
6868
exit 1
6969
fi
7070

7171
TMP=${TMPDIR:-/tmp}/mkdep$$
7272

73-
trap 'rm -f $TMP ; exit 1' 1 2 3 13 15
73+
trap 'rm -f "$TMP" ; exit 1' HUP INT QUIT PIPE TERM
7474

75-
cp $MAKE ${MAKE}.bak
75+
cp "$MAKE" "${MAKE}.bak"
7676

77-
sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP
77+
sed -e '/DO NOT DELETE THIS LINE/,$d' < "$MAKE" > "$TMP"
7878

79-
cat << _EOF_ >> $TMP
79+
cat << _EOF_ >> "$TMP"
8080
# DO NOT DELETE THIS LINE -- mkdep uses it.
8181
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
8282
@@ -94,23 +94,25 @@ _EOF_
9494
# Construct a list of source files with paths relative to the source directory.
9595
#
9696
sources=""
97-
for srcfile in $*
97+
for srcfile in "$@"
9898
do
9999
sources="$sources $SOURCE_DIRECTORY/$srcfile"
100100
done
101101

102102
# XXX this doesn't work with things like "-DDECLWAITSTATUS=union\ wait"
103-
$CC $DEPENDENCY_CFLAG $flags $sources |
103+
# $flags and $sources are meant to expand
104+
# shellcheck disable=SC2086
105+
"$CC" "$DEPENDENCY_CFLAG" $flags $sources |
104106
sed "
105107
s; \./; ;g
106-
$SED" >> $TMP
108+
$SED" >> "$TMP"
107109

108-
cat << _EOF_ >> $TMP
110+
cat << _EOF_ >> "$TMP"
109111
110112
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
111113
_EOF_
112114

113115
# copy to preserve permissions
114-
cp $TMP $MAKE
115-
rm -f ${MAKE}.bak $TMP
116+
cp "$TMP" "$MAKE"
117+
rm -f "${MAKE}.bak" "$TMP"
116118
exit 0

0 commit comments

Comments
 (0)