summaryrefslogtreecommitdiff
path: root/scripts/fixrmtab.in
diff options
context:
space:
mode:
authorCy Schubert <cy@FreeBSD.org>2016-08-31 00:08:49 +0000
committerCy Schubert <cy@FreeBSD.org>2016-08-31 00:08:49 +0000
commitca57057f598bfc7119f79f71bf38ec88244ab396 (patch)
tree051f78ef258707b493cc7cb21569b6949915f6c7 /scripts/fixrmtab.in
parente66b16bf080ead1c51f321eaf56710c771778706 (diff)
Notes
Diffstat (limited to 'scripts/fixrmtab.in')
-rwxr-xr-xscripts/fixrmtab.in20
1 files changed, 14 insertions, 6 deletions
diff --git a/scripts/fixrmtab.in b/scripts/fixrmtab.in
index 23003806e4c0..a1fbebf61507 100755
--- a/scripts/fixrmtab.in
+++ b/scripts/fixrmtab.in
@@ -10,15 +10,23 @@
#set -x
-RMTAB=/etc/rmtab
-TMP=/tmp/rmtab.$$
+# allow user to pass RMTAB file name from environment
+if test -z "${RMTAB}" ; then
+ RMTAB=/etc/rmtab
+fi
-if [ ! -f /etc/rmtab ]; then
+if [ ! -f "$RMTAB" ]; then
exit 0
fi
-for host in $*
+TMP="$(mktemp ${RMTAB}.XXXXXX)"
+if [ -z "$TMP" ]; then
+ exit 1
+fi
+
+trap "rm -f $TMP" 0 1 2 3 15
+
+for host
do
- sed -e '/^'$host':/s/^./#/' $RMTAB > $TMP && cp $TMP $RMTAB
+ sed -e "/^$host:/s/^./#/" "$RMTAB" > "$TMP" && cp "$TMP" "$RMTAB"
done
-rm -f $TMP