aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-14 14:39:09 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-14 14:39:48 +1200
commit2d20e84c042832eda21b557b015cfa9ba53439af (patch)
treeda78d68149182354567e1ffd08eaa4de090bff2f
parentAdd tentative enhancements to br(1) (diff)
downloaddotfiles-2d20e84c042832eda21b557b015cfa9ba53439af.tar.gz
dotfiles-2d20e84c042832eda21b557b015cfa9ba53439af.zip
Add sd2u(1) and su2d(1)
-rw-r--r--.gitignore2
-rw-r--r--Makefile14
-rw-r--r--README.markdown3
-rw-r--r--bin/sd2u.sed2
-rw-r--r--bin/su2d.sed2
-rw-r--r--man/man1/d2u.12
-rw-r--r--man/man1/sd2u.121
-rw-r--r--man/man1/su2d.120
-rw-r--r--man/man1/u2d.12
9 files changed, 64 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index a6389b7d..45f195cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+bin/sd2u
+bin/su2d
bin/unf
games/acq
games/kvlt
diff --git a/Makefile b/Makefile
index 89dc5ab2..599eb315 100644
--- a/Makefile
+++ b/Makefile
@@ -60,10 +60,12 @@ EMAIL := tom@sanctum.geek.nz
KEY := 0xC14286EA77BB8872
SENDMAIL := /usr/bin/msmtp
-all : bin/unf git/gitconfig gnupg/gpg.conf
+all : bin/sd2u bin/su2d bin/unf git/gitconfig gnupg/gpg.conf
clean distclean :
rm -f \
+ bin/sd2u \
+ bin/su2d \
bin/unf \
games/acq \
games/kvlt \
@@ -74,6 +76,14 @@ clean distclean :
mutt/muttrc \
tmux/tmux.conf
+bin/sd2u : bin/sd2u.sed
+ bin/shb bin/sd2u.sed sed -f > "$@"
+ chmod +x "$@"
+
+bin/su2d : bin/su2d.sed
+ bin/shb bin/su2d.sed sed -f > "$@"
+ chmod +x "$@"
+
bin/unf : bin/unf.sed
bin/shb bin/unf.sed sed -f > "$@"
chmod +x "$@"
@@ -150,7 +160,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 : bin/unf test-bin install-bin-man
+install-bin : bin/sd2u bin/su2d 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 3b5ecb8d..a4a2dd3c 100644
--- a/README.markdown
+++ b/README.markdown
@@ -325,6 +325,9 @@ Installed by the `install-bin` target:
* Two file formatting scripts:
* `d2u(1)` converts DOS line endings in files to UNIX ones.
* `u2d(1)` converts UNIX line endings in files to DOS ones.
+* Two stream formatting scripts:
+ * `sd2u(1)` converts DOS line endings in streams to UNIX ones.
+ * `su2d(1)` converts UNIX line endings in streams to DOS ones.
* `apf(1)` prepends arguments to a command with ones read from a file,
intended as a framework for shell functions.
* `ax(1)` evaluates an awk expression given on the command line; this is
diff --git a/bin/sd2u.sed b/bin/sd2u.sed
new file mode 100644
index 00000000..14588623
--- /dev/null
+++ b/bin/sd2u.sed
@@ -0,0 +1,2 @@
+# Convert DOS line endings to UNIX ones
+s/\r$//g
diff --git a/bin/su2d.sed b/bin/su2d.sed
new file mode 100644
index 00000000..06998986
--- /dev/null
+++ b/bin/su2d.sed
@@ -0,0 +1,2 @@
+# Convert UNIX line endings to DOS ones
+/[^\r]$/s/$/\r/g
diff --git a/man/man1/d2u.1 b/man/man1/d2u.1
index 33e07cb5..d42b87b9 100644
--- a/man/man1/d2u.1
+++ b/man/man1/d2u.1
@@ -8,6 +8,6 @@
Applies ed(1) to change DOS \\r\\n (CRLF) line endings to UNIX \\n line
endings. Files already in UNIX format should be unchanged.
.SH SEE ALSO
-ed(1), u2d(1)
+ed(1), u2d(1), sd2u(1), su2d(1)
.SH AUTHOR
Tom Ryder <tom@sanctum.geek.nz>
diff --git a/man/man1/sd2u.1 b/man/man1/sd2u.1
new file mode 100644
index 00000000..2903447c
--- /dev/null
+++ b/man/man1/sd2u.1
@@ -0,0 +1,21 @@
+.TH SD2U 1 "August 2016" "Manual page for sd2u"
+.SH NAME
+.B sd2u
+\- change text stream from DOS to UNIX format
+.SH USAGE
+.B sd2u
+FILE1 [FILE2 ...]
+.br
+.B sd2u
+< FILE
+.br
+program |
+.B sd2u
+.B sd2u
+.SH DESCRIPTION
+Applies sed(1) to change DOS \\r\\n (CRLF) line endings to UNIX \\n line
+endings. Lines already in UNIX format should be unchanged.
+.SH SEE ALSO
+sed(1), su2d(1), d2u(1), u2d(1)
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>
diff --git a/man/man1/su2d.1 b/man/man1/su2d.1
new file mode 100644
index 00000000..6dc71787
--- /dev/null
+++ b/man/man1/su2d.1
@@ -0,0 +1,20 @@
+.TH SU2D 1 "August 2016" "Manual page for su2d"
+.SH NAME
+.B su2d
+\- change text files from UNIX to DOS format
+.SH USAGE
+.B su2d
+FILE1 [FILE2 ...]
+.br
+.B su2d
+< FILE
+.br
+program |
+.B su2d
+.SH DESCRIPTION
+Applies sed(1) to change UNIX \\n line endings to DOS \\r\\n (CRLF) line
+endings. Lines already in DOS format should be unchanged.
+.SH SEE ALSO
+sed(1), sd2u(1), d2u(1), u2d(1)
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>
diff --git a/man/man1/u2d.1 b/man/man1/u2d.1
index 48dfaeb5..271b28ac 100644
--- a/man/man1/u2d.1
+++ b/man/man1/u2d.1
@@ -8,6 +8,6 @@
Applies ed(1) to change UNIX \\n line endings to DOS \\r\\n (CRLF) line
endings. Files already in DOS format should be unchanged.
.SH SEE ALSO
-ed(1), d2u(1)
+ed(1), d2u(1), sd2u(1), su2d(1)
.SH AUTHOR
Tom Ryder <tom@sanctum.geek.nz>