aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-12-03 01:21:00 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-12-03 01:21:00 +1300
commite43633aa54c25918ff9dd8a89f91b8342fe66e06 (patch)
treec7e894881c3616be727d8bde32247ee52a5dd333
parentAdd another issue (diff)
downloaddotfiles-e43633aa54c25918ff9dd8a89f91b8342fe66e06.tar.gz
dotfiles-e43633aa54c25918ff9dd8a89f91b8342fe66e06.zip
Convert sd2u and su2d to awk
-rw-r--r--ISSUES.markdown2
-rw-r--r--bin/sd2u.awk (renamed from bin/sd2u.sed)3
-rw-r--r--bin/su2d.awk (renamed from bin/su2d.sed)3
-rw-r--r--man/man1/sd2u.1df4
-rw-r--r--man/man1/su2d.1df4
5 files changed, 8 insertions, 8 deletions
diff --git a/ISSUES.markdown b/ISSUES.markdown
index 9042d3ba..19177f71 100644
--- a/ISSUES.markdown
+++ b/ISSUES.markdown
@@ -26,5 +26,3 @@ Known issues
* dr(1df) is probably more practical in awk
* unf(1df) doesn't work on NetBSD sed(1); might be time to give up and
rewrite it in awk
-* sd2u(1df) and su2d(1df) are not portable because \r in the replacement text
- is not POSIX. Again, best bet is awk. *sigh*
diff --git a/bin/sd2u.sed b/bin/sd2u.awk
index 14588623..87f710b2 100644
--- a/bin/sd2u.sed
+++ b/bin/sd2u.awk
@@ -1,2 +1,3 @@
# Convert DOS line endings to UNIX ones
-s/\r$//g
+{ sub(/\r$/, "") }
+1
diff --git a/bin/su2d.sed b/bin/su2d.awk
index 06998986..f9160ab0 100644
--- a/bin/su2d.sed
+++ b/bin/su2d.awk
@@ -1,2 +1,3 @@
# Convert UNIX line endings to DOS ones
-/[^\r]$/s/$/\r/g
+!/\r$/ { $0 = $0 "\r" }
+1
diff --git a/man/man1/sd2u.1df b/man/man1/sd2u.1df
index bf671bd4..f07ebdb9 100644
--- a/man/man1/sd2u.1df
+++ b/man/man1/sd2u.1df
@@ -12,9 +12,9 @@ FILE1 [FILE2 ...]
program |
.B sd2u
.SH DESCRIPTION
-Applies sed(1) to change DOS \\r\\n (CRLF) line endings to UNIX \\n line
+Applies awk(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(1df), d2u(1df), u2d(1df)
+awk(1), su2d(1df), d2u(1df), u2d(1df)
.SH AUTHOR
Tom Ryder <tom@sanctum.geek.nz>
diff --git a/man/man1/su2d.1df b/man/man1/su2d.1df
index 7de9ec03..aa6a8821 100644
--- a/man/man1/su2d.1df
+++ b/man/man1/su2d.1df
@@ -12,9 +12,9 @@ FILE1 [FILE2 ...]
program |
.B su2d
.SH DESCRIPTION
-Applies sed(1) to change UNIX \\n line endings to DOS \\r\\n (CRLF) line
+Applies awk(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(1df), d2u(1df), u2d(1df)
+awk(1), sd2u(1df), d2u(1df), u2d(1df)
.SH AUTHOR
Tom Ryder <tom@sanctum.geek.nz>