aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-14 13:46:26 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-14 13:46:26 +1200
commitfbd4583876ac9dbf5c94959bee25aea85f114109 (patch)
tree0ea067dbf38835c1f1197687f831bcd7fd586f4d
parentMake brxs(1) executable (diff)
downloaddotfiles-fbd4583876ac9dbf5c94959bee25aea85f114109.tar.gz
dotfiles-fbd4583876ac9dbf5c94959bee25aea85f114109.zip
Add unf(1)
-rw-r--r--.gitignore1
-rw-r--r--Makefile9
-rw-r--r--README.markdown2
-rw-r--r--bin/unf.sed17
-rw-r--r--man/man1/unf.122
5 files changed, 49 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 3b1703a5..a6389b7d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+bin/unf
games/acq
games/kvlt
games/zs
diff --git a/Makefile b/Makefile
index 937e9528..89dc5ab2 100644
--- a/Makefile
+++ b/Makefile
@@ -60,10 +60,11 @@ EMAIL := tom@sanctum.geek.nz
KEY := 0xC14286EA77BB8872
SENDMAIL := /usr/bin/msmtp
-all : git/gitconfig gnupg/gpg.conf
+all : bin/unf git/gitconfig gnupg/gpg.conf
clean distclean :
rm -f \
+ bin/unf \
games/acq \
games/kvlt \
games/zs \
@@ -73,6 +74,10 @@ clean distclean :
mutt/muttrc \
tmux/tmux.conf
+bin/unf : bin/unf.sed
+ bin/shb bin/unf.sed sed -f > "$@"
+ chmod +x "$@"
+
games/acq : games/acq.sed
bin/shb games/acq.sed sed -f > "$@"
chmod +x "$@"
@@ -145,7 +150,7 @@ install-bash-completion : install-bash
install -pm 0644 -- bash/bash_completion "$(HOME)"/.config/bash_completion
install -pm 0644 -- bash/bash_completion.d/* "$(HOME)"/.bash_completion.d
-install-bin : test-bin install-bin-man
+install-bin : bin/unf test-bin install-bin-man
install -m 0755 -d -- "$(HOME)"/.local/bin
install -m 0755 -- bin/* "$(HOME)"/.local/bin
diff --git a/README.markdown b/README.markdown
index 4d3bf251..e6568105 100644
--- a/README.markdown
+++ b/README.markdown
@@ -383,6 +383,8 @@ Installed by the `install-bin` target:
* `try(1)` repeats a command up to a given number of times until it succeeds,
only printing error output if all three attempts failed. Good for
tolerating blips or temporary failures in `cron(8)` scripts.
+* `unf(1)` joins lines with leading spaces to the previous line. Intended for
+ unfolding HTTP headers, but it should work for most RFC 822 formats.
There's some silly stuff in `install-games`:
diff --git a/bin/unf.sed b/bin/unf.sed
new file mode 100644
index 00000000..23270fc6
--- /dev/null
+++ b/bin/unf.sed
@@ -0,0 +1,17 @@
+# Unfold lines with leading spaces (e.g. RFC 822 headers)
+/^[ \t]/!{
+ 1!{
+ x
+ p
+ x
+ }
+ h
+}
+/^[ \t]/{
+ H
+ x
+ s/[\r\n]//g
+ x
+}
+$!d
+x
diff --git a/man/man1/unf.1 b/man/man1/unf.1
new file mode 100644
index 00000000..709e7d2b
--- /dev/null
+++ b/man/man1/unf.1
@@ -0,0 +1,22 @@
+.TH UNF 1 "August 2016" "Manual page for unf"
+.SH NAME
+.B unf
+\- join lines with leading spaces to the previous line
+.SH USAGE
+.B unf
+FILE
+.br
+.B unf
+<FILE
+.br
+.B unf
+FILE1 FILE2...
+.br
+curl -I http://www.example.net/ |
+.B
+unf
+.SH DESCRIPTION
+Joins lines with leading spaces in the output to the previous line,
+such as folded header fields in RFC 822 format messages.
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>