From ba2059e293e79e8353a546a0782e5aecee8893f0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 16 Aug 2016 21:08:56 +1200 Subject: Swap td(1) for mktemp(1) in edda(1) --- bin/edda | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'bin') 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 -- cgit v1.2.3