aboutsummaryrefslogtreecommitdiff
path: root/bin/try
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-19 23:22:51 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-19 23:22:51 +1200
commit6daae9a75afa12f929be810a52ad21139233adfa (patch)
tree409f8935029dca341ee4809581d375bd3a42cae4 /bin/try
parentMerge branch 'master' into freebsd (diff)
parentUpdate documentation for br(1) and xgo(1) (diff)
downloaddotfiles-6daae9a75afa12f929be810a52ad21139233adfa.tar.gz
dotfiles-6daae9a75afa12f929be810a52ad21139233adfa.zip
Merge branch 'master' into freebsd
Diffstat (limited to 'bin/try')
-rwxr-xr-xbin/try5
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/try b/bin/try
index f0ba317d..7d6d57a8 100755
--- a/bin/try
+++ b/bin/try
@@ -26,7 +26,8 @@ if [ "$#" -eq 0 ] ; then
exit 2
fi
-# Create a buffer file for the error output, and clean up the file when we exit
+# Create a temporary directory with name in $td, and handle POSIX-ish traps to
+# remove it when the script exits.
td=
cleanup() {
[ -n "$td" ] && rm -fr -- "$td"
@@ -40,9 +41,9 @@ for sig in EXIT HUP INT TERM ; do
trap "cleanup $sig" "$sig"
done
td=$(mktd "$self") || exit
-errbuff=$td/errbuff
# Open a filehandle to the error buffer, just to save on file operations
+errbuff=$td/errbuff
exec 3>"$errbuff"
# Keep trying the command, writing error output to the buffer file, and exit