aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-16 19:49:35 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-16 19:49:35 +1200
commit6cbb1755813b9fd3ad016aafc202a36eda37718a (patch)
treed7d985980ef5fa78572f13b867d6b0bdfd9f3a24 /bin
parentApply suffix rules for games/bin building (diff)
downloaddotfiles-6cbb1755813b9fd3ad016aafc202a36eda37718a.tar.gz
dotfiles-6cbb1755813b9fd3ad016aafc202a36eda37718a.zip
Reverse .m4 translation for binscripts
Either this is overengineering, or I don't understand m4 well enough.
Diffstat (limited to 'bin')
-rwxr-xr-x[-rw-r--r--]bin/rndl (renamed from bin/rndl.m4)17
-rwxr-xr-x[-rw-r--r--]bin/tlcs (renamed from bin/tlcs.m4)17
-rwxr-xr-x[-rw-r--r--]bin/try (renamed from bin/try.m4)17
-rwxr-xr-x[-rw-r--r--]bin/urlc (renamed from bin/urlc.m4)17
4 files changed, 64 insertions, 4 deletions
diff --git a/bin/rndl.m4 b/bin/rndl
index 536f5c21..7d5cb6b7 100644..100755
--- a/bin/rndl.m4
+++ b/bin/rndl
@@ -8,7 +8,22 @@ self=rndl
# file if we don't want to read all of the input into memory (!)
if [ "$#" -eq 0 ] ; then
-include(`include/mktd.trap.sh')
+ # 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"
+ if [ "$1" != EXIT ] ; then
+ trap - "$1"
+ kill "-$1" "$$"
+ fi
+ }
+ for sig in EXIT HUP INT TERM ; do
+ # shellcheck disable=SC2064
+ trap "cleanup $sig" "$sig"
+ done
+ td=$(mktd "$self") || exit
+
# We'll operate on stdin in the temp directory; write the script's stdin to
# it with cat(1)
set -- "$td"/stdin
diff --git a/bin/tlcs.m4 b/bin/tlcs
index ff01cc0d..30068303 100644..100755
--- a/bin/tlcs.m4
+++ b/bin/tlcs
@@ -67,7 +67,22 @@ if [ "$((color_count >= 8))" -eq 1 ] ; then
fi
fi
-include(`include/mktd.trap.sh')
+# 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"
+ if [ "$1" != EXIT ] ; then
+ trap - "$1"
+ kill "-$1" "$$"
+ fi
+}
+for sig in EXIT HUP INT TERM ; do
+ # shellcheck disable=SC2064
+ trap "cleanup $sig" "$sig"
+done
+td=$(mktd "$self") || exit
+
# Execute the command, passing stdout and stderr to tl(1) calls as appropriate
# via named pipes
out=$td/out err=$td/err
diff --git a/bin/try.m4 b/bin/try
index 359a4280..7d6d57a8 100644..100755
--- a/bin/try.m4
+++ b/bin/try
@@ -26,7 +26,22 @@ if [ "$#" -eq 0 ] ; then
exit 2
fi
-include(`include/mktd.trap.sh')
+# 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"
+ if [ "$1" != EXIT ] ; then
+ trap - "$1"
+ kill "-$1" "$$"
+ fi
+}
+for sig in EXIT HUP INT TERM ; do
+ # shellcheck disable=SC2064
+ trap "cleanup $sig" "$sig"
+done
+td=$(mktd "$self") || exit
+
# Open a filehandle to the error buffer, just to save on file operations
errbuff=$td/errbuff
exec 3>"$errbuff"
diff --git a/bin/urlc.m4 b/bin/urlc
index c49c1ecf..e306d48f 100644..100755
--- a/bin/urlc.m4
+++ b/bin/urlc
@@ -5,7 +5,22 @@ self=urlc
# cURL request timeout
tm=${URLCHECK_TIMEOUT:-8}
-include(`include/mktd.trap.sh')
+# 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"
+ if [ "$1" != EXIT ] ; then
+ trap - "$1"
+ kill "-$1" "$$"
+ fi
+}
+for sig in EXIT HUP INT TERM ; do
+ # shellcheck disable=SC2064
+ trap "cleanup $sig" "$sig"
+done
+td=$(mktd "$self") || exit
+
# Create buffer files for the headers and body content, to be cleaned up on
# exit
list=$td/list head=$td/head body=$td/body