aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/edda15
1 files changed, 10 insertions, 5 deletions
diff --git a/bin/edda b/bin/edda
index 5e6f4ec4..e35cdcff 100755
--- a/bin/edda
+++ b/bin/edda
@@ -25,15 +25,20 @@ if ! (($#)) ; then
exit 2
fi
-# Duplicate stdin into a file, which we'll remove on exit
-stdin=$(mktemp -t "$self".XXXXXX) || exit
+# Create a temporary directory with name in $td, and a trap to remove it when
+# the script exits
+td=
cleanup() {
- rm -f -- "$stdin"
+ [[ -n "$td" ]] && rm -fr -- "$td"
}
trap cleanup EXIT
-cat > "$stdin"
+td=$(mktd "$self") || exit
+
+# Duplicate stdin into a file
+script=$td/$stdin
+cat >"$script" || exit
# Run ed(1) over each file with the options and stdin given
for file ; do
- ed "${opts[@]}" -- "$file" < "$stdin"
+ ed "${opts[@]}" -- "$file" <"$script"
done