summaryrefslogtreecommitdiffstats
path: root/mkdep
diff options
context:
space:
mode:
Diffstat (limited to 'mkdep')
-rwxr-xr-xmkdep28
1 files changed, 15 insertions, 13 deletions
diff --git a/mkdep b/mkdep
index caf547e..dc0a11e 100755
--- a/mkdep
+++ b/mkdep
@@ -1,4 +1,4 @@
-#!/bin/sh -
+#!/bin/sh -e
#
# Copyright (c) 1994, 1996
# The Regents of the University of California. All rights reserved.
@@ -63,20 +63,20 @@ if [ $# = 0 ] ; then
exit 1
fi
-if [ ! -w $MAKE ]; then
+if [ ! -w "$MAKE" ]; then
echo "mkdep: no writeable file \"$MAKE\""
exit 1
fi
-TMP=/tmp/mkdep$$
+TMP=${TMPDIR:-/tmp}/mkdep$$
-trap 'rm -f $TMP ; exit 1' 1 2 3 13 15
+trap 'rm -f "$TMP" ; exit 1' HUP INT QUIT PIPE TERM
-cp $MAKE ${MAKE}.bak
+cp "$MAKE" "${MAKE}.bak"
-sed -e '/DO NOT DELETE THIS LINE/,$d' < $MAKE > $TMP
+sed -e '/DO NOT DELETE THIS LINE/,$d' < "$MAKE" > "$TMP"
-cat << _EOF_ >> $TMP
+cat << _EOF_ >> "$TMP"
# DO NOT DELETE THIS LINE -- mkdep uses it.
# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
@@ -94,23 +94,25 @@ _EOF_
# Construct a list of source files with paths relative to the source directory.
#
sources=""
-for srcfile in $*
+for srcfile in "$@"
do
sources="$sources $SOURCE_DIRECTORY/$srcfile"
done
# XXX this doesn't work with things like "-DDECLWAITSTATUS=union\ wait"
-$CC $DEPENDENCY_CFLAG $flags $sources |
+# $flags and $sources are meant to expand
+# shellcheck disable=SC2086
+"$CC" "$DEPENDENCY_CFLAG" $flags $sources |
sed "
s; \./; ;g
- $SED" >> $TMP
+ $SED" >> "$TMP"
-cat << _EOF_ >> $TMP
+cat << _EOF_ >> "$TMP"
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
_EOF_
# copy to preserve permissions
-cp $TMP $MAKE
-rm -f ${MAKE}.bak $TMP
+cp "$TMP" "$MAKE"
+rm -f "${MAKE}.bak" "$TMP"
exit 0