diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-05-24 16:12:35 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-05-24 16:12:35 +1200 |
commit | 6ff90f1b613fa01098d2ad7fe38a56444c4fa1a7 (patch) | |
tree | c9e9ba2b87016fd2a8daa5b5433d5d0ba2119bba | |
parent | Add missing dash (diff) | |
download | dotfiles-6ff90f1b613fa01098d2ad7fe38a56444c4fa1a7.tar.gz dotfiles-6ff90f1b613fa01098d2ad7fe38a56444c4fa1a7.zip |
Change dam(1df) to a sed script
-rw-r--r-- | bin/dam.sed | 8 | ||||
-rw-r--r-- | bin/dam.sh | 25 | ||||
-rw-r--r-- | man/man1/dam.1df | 5 |
3 files changed, 11 insertions, 27 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 diff --git a/man/man1/dam.1df b/man/man1/dam.1df index b9821960..78f5210c 100644 --- a/man/man1/dam.1df +++ b/man/man1/dam.1df @@ -9,7 +9,8 @@ dam | prog2 .SH DESCRIPTION .B dam -stores all its input in a temporary file before emitting it as output, behaving -like a fully-buffered cat(1), and with some of the functionality of sponge(1). +buffers all its input before emitting it as output. Useful if you don't +actually want a line-by-line flow between programs, such as pasting a complete +document into a sed(1) pipeline on the terminal. .SH AUTHOR Tom Ryder <tom@sanctum.geek.nz> |