diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2017-11-03 14:05:59 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2017-11-03 14:19:08 +1300 |
commit | 0b3aa702497fe3fa690a31998f3c7aedb96e5c73 (patch) | |
tree | 0fea4580e7776e5886250388550aec2858fd1fb3 | |
parent | Merge branch 'release/v0.4.0' (diff) | |
download | dotfiles-0b3aa702497fe3fa690a31998f3c7aedb96e5c73.tar.gz dotfiles-0b3aa702497fe3fa690a31998f3c7aedb96e5c73.zip |
Make d2u(1df)/u2d(1df) like their stream analogues
Remove the idempotency guarantee, and simplify the ed(1) scripts. See
commits 2905980 and cd8e9cc:
>commit 29059804f7708413843687c1764bc845d374a82d
>Author: Tom Ryder <tom@sanctum.geek.nz>
>Date: Fri Nov 3 13:58:23 2017
>
> Remove idempotency assert for sd2u(1df)/su2d(1df)
>
> Commit cd8e9cc applies a cleaner implementation of these tools but
> loses the idempotency:
>
> * Repeated su2d applications will result in double \r, so \r\r\n
> * Repeated s2ru applications will result in an extra newline at the
> end of the file, because the whole file will be interpreted as
> one line
>
> However, I am OK with this, as I think of the operation as simpler
> and more predictable, and I wouldn't apply it as a means to "force"
> a file of unknown or various line-ending types to one type.
>
>commit cd8e9cc27f7dd9d360b64f4a34b8c2d048f42e45
>Author: Tom Ryder <tom@sanctum.geek.nz>
>Date: Fri Nov 3 13:46:30 2017
>
> Apply simpler method for sd2u(1df) and su2d(1df)
>
> This method is shorter, easier to read, and more idiomatic.
-rw-r--r-- | bin/d2u.sh | 2 | ||||
-rw-r--r-- | bin/u2d.sh | 3 | ||||
-rw-r--r-- | man/man1/d2u.1df | 2 | ||||
-rw-r--r-- | man/man1/u2d.1df | 2 |
4 files changed, 4 insertions, 5 deletions
@@ -16,7 +16,7 @@ for fn ; do # $r within it to get a literal carriage return; the escape characters # prescribed for ed(1) by POSIX are very limited ed -s -- "$fn" <<EOF || ex=1 -g/$r\$/ s/$r\$// +,s/$r\$// w EOF done @@ -16,8 +16,7 @@ for fn ; do # $r within it to get a literal carriage return; the escape characters # prescribed for ed(1) by POSIX are very limited ed -s -- "$fn" <<EOF || ex=1 -g/[^$r]\$/ s/\$/$r/ -g/^\$/ s/\$/$r/ +,s/\$/$r/ w EOF done diff --git a/man/man1/d2u.1df b/man/man1/d2u.1df index 18c27829..c652434c 100644 --- a/man/man1/d2u.1df +++ b/man/man1/d2u.1df @@ -6,7 +6,7 @@ .B d2u FILE1 [FILE2 ...] .SH DESCRIPTION Applies ed(1) to change DOS \\r\\n (CRLF) line endings to UNIX \\n line -endings. Files already in UNIX format should be unchanged. +endings. .SH SEE ALSO ed(1), u2d(1df), sd2u(1df), su2d(1df) .SH AUTHOR diff --git a/man/man1/u2d.1df b/man/man1/u2d.1df index 3bb16092..9af792bf 100644 --- a/man/man1/u2d.1df +++ b/man/man1/u2d.1df @@ -6,7 +6,7 @@ .B u2d FILE1 [FILE2 ...] .SH DESCRIPTION Applies ed(1) to change UNIX \\n line endings to DOS \\r\\n (CRLF) line -endings. Files already in DOS format should be unchanged. +endings. .SH SEE ALSO ed(1), d2u(1df), sd2u(1df), su2d(1df) .SH AUTHOR |