diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-16 21:08:56 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-08-16 21:08:56 +1200 |
commit | ba2059e293e79e8353a546a0782e5aecee8893f0 (patch) | |
tree | bfe3c1e88d1c74b6ee221f2bb0ef8acd5ba9d60c /bin/edda | |
parent | Simplify help in edda(1) and eds(1) (diff) | |
download | dotfiles-ba2059e293e79e8353a546a0782e5aecee8893f0.tar.gz dotfiles-ba2059e293e79e8353a546a0782e5aecee8893f0.zip |
Swap td(1) for mktemp(1) in edda(1)
Diffstat (limited to 'bin/edda')
-rwxr-xr-x | bin/edda | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -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 |