aboutsummaryrefslogtreecommitdiff
path: root/bin/try
diff options
context:
space:
mode:
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