aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/fixrmtab.in
diff options
context:
space:
mode:
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