aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-16 21:08:56 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-16 21:08:56 +1200
commitba2059e293e79e8353a546a0782e5aecee8893f0 (patch)
treebfe3c1e88d1c74b6ee221f2bb0ef8acd5ba9d60c /bin
parentSimplify help in edda(1) and eds(1) (diff)
downloaddotfiles-ba2059e293e79e8353a546a0782e5aecee8893f0.tar.gz
dotfiles-ba2059e293e79e8353a546a0782e5aecee8893f0.zip
Swap td(1) for mktemp(1) in edda(1)
Diffstat (limited to 'bin')
-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