aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-05-24 16:12:35 +1200
committerTom Ryder <tom@sanctum.geek.nz>2017-05-24 16:12:35 +1200
commit6ff90f1b613fa01098d2ad7fe38a56444c4fa1a7 (patch)
treec9e9ba2b87016fd2a8daa5b5433d5d0ba2119bba /bin
parentAdd missing dash (diff)
downloaddotfiles-6ff90f1b613fa01098d2ad7fe38a56444c4fa1a7.tar.gz
dotfiles-6ff90f1b613fa01098d2ad7fe38a56444c4fa1a7.zip
Change dam(1df) to a sed script
Diffstat (limited to 'bin')
-rw-r--r--bin/dam.sed8
-rw-r--r--bin/dam.sh25
2 files changed, 8 insertions, 25 deletions
diff --git a/bin/dam.sed b/bin/dam.sed
new file mode 100644
index 00000000..86fb03f9
--- /dev/null
+++ b/bin/dam.sed
@@ -0,0 +1,8 @@
+# Store up all input before emitting it unchanged as output
+1h
+1!H
+$ {
+ g
+ p
+}
+d
diff --git a/bin/dam.sh b/bin/dam.sh
deleted file mode 100644
index a80cae4a..00000000
--- a/bin/dam.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-# Store up all input before emitting it unchanged as output
-self=dam
-
-# 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)
-cat -- "${@:--}" >"$td"/stdin
-
-# Only when that write is finished do we finally spit it all back out again
-cat -- "$td"/stdin