about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-12-17 00:45:59 +0100
committerLeah Neukirchen <leah@vuxu.org>2017-12-17 00:45:59 +0100
commit5e9f8c0865f99fe4d614dc69c82eb1ca74ec363e (patch)
tree4e793f868195ed1aecddb5169b2fdd131fc3b478
parent3d937d13bf77a2cda41a0a9ba8fc6d1e7885cf70 (diff)
downloadrnl-5e9f8c0865f99fe4d614dc69c82eb1ca74ec363e.tar.gz
rnl-5e9f8c0865f99fe4d614dc69c82eb1ca74ec363e.tar.xz
rnl-5e9f8c0865f99fe4d614dc69c82eb1ca74ec363e.zip
rename arguments
-rw-r--r--README14
-rw-r--r--rnl.120
-rw-r--r--rnl.c18
-rwxr-xr-xt/0.t63
-rwxr-xr-xt/1.t76
-rwxr-xr-xt/a.t63
-rwxr-xr-xt/o.t76
7 files changed, 165 insertions, 165 deletions
diff --git a/README b/README
index edb4f45..79c0076 100644
--- a/README
+++ b/README
@@ -1,27 +1,27 @@
 RNL(1)                      General Commands Manual                     RNL(1)
 
 NAME
-     rnl – remove trailing newlines
+     rnl – remove final newlines
 
 SYNOPSIS
      rnl [-01sz] [files ...]
 
 DESCRIPTION
-     rnl removes trailing newlines from the specified input files.  The files
-     are modified in-place!
+     rnl removes final newlines from the specified input files.  The files are
+     modified in-place!
 
      When used without arguments, rnl copies standard input to standard
-     output, removing trailing newlines.
+     output, removing final newlines.
 
      The options are as follows:
 
-     -0      Remove all trailing newlines.
+     -0      Remove final NUL bytes instead of newlines.
 
-     -1      Remove just one trailing newline.
+     -a      Remove all final newlines.
 
      -s      Strip all but one newline at the end.  (This is the default.)
 
-     -z      Remove final NUL bytes instead of newlines.
+     -o      Remove just one final newline.
 
 EXIT STATUS
      The rnl utility exits 0 on success, and >0 if an error occurs.
diff --git a/rnl.1 b/rnl.1
index 38c6769..07abc1c 100644
--- a/rnl.1
+++ b/rnl.1
@@ -3,37 +3,37 @@
 .Os
 .Sh NAME
 .Nm rnl
-.Nd remove trailing newlines
+.Nd remove final newlines
 .Sh SYNOPSIS
 .Nm
 .Op Fl 01sz
 .Op Ar files\ ...
 .Sh DESCRIPTION
 .Nm
-removes trailing newlines from the specified input
+removes final newlines from the specified input
 .Ar files .
 The files are modified in-place!
 .Pp
 When used without arguments,
 .Nm
 copies standard input to standard output,
-removing trailing newlines.
+removing final newlines.
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
 .It Fl 0
+Remove final NUL bytes instead of newlines.
+.It Fl a
 Remove
 .Em all
-trailing newlines.
-.It Fl 1
-Remove just
-.Em one
-trailing newline.
+final newlines.
 .It Fl s
 Strip all but one newline at the end.
 (This is the default.)
-.It Fl z
-Remove final NUL bytes instead of newlines.
+.It Fl o
+Remove just
+.Em one
+final newline.
 .El
 .Sh EXIT STATUS
 .Ex -std
diff --git a/rnl.c b/rnl.c
index b23abbb..594e5c5 100644
--- a/rnl.c
+++ b/rnl.c
@@ -17,20 +17,20 @@ main(int argc, char *argv[])
 	int mode = -1;
 	char nl = '\n';
 
-	while ((c = getopt(argc, argv, "01sz")) != -1)
+	while ((c = getopt(argc, argv, "0aso")) != -1)
 		switch (c) {
-		case '0': mode = 0; break;
-		case '1': mode = 1; break;
+		case '0': nl = '\0'; break;
+		case 'a': mode = 0; break;
 		case 's': mode = -1; break;
-		case 'z': nl = '\0'; break;
+		case 'o': mode = 1; break;
 		default:
 			fprintf(stderr,
-"Usage: %s [-01sz] < INPUT           writes to stdout\n"
-"       %s [-01sz] INPUT...          modifies in-place!\n"
-"  -0  strip all newlines at end\n"
-"  -1  strip one newline at end\n"
+"Usage: %s [-0aso] < INPUT           writes to stdout\n"
+"       %s [-0aso] INPUT...          modifies files in-place!\n"
+"  -0  strip NUL bytes instead of newlines\n"
+"  -a  strip all newlines at end\n"
 "  -s  default: strip all but one newline at end\n"
-"  -z  strip NUL bytes instead of newlines\n",
+"  -o  strip one newline at end\n",
 			    argv[0], argv[0]);
 			exit(1);
 		}
diff --git a/t/0.t b/t/0.t
deleted file mode 100755
index c6e999c..0000000
--- a/t/0.t
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/sh
-
-export "PATH=.:$PATH"
-
-printf '1..11\n'
-printf '# error handling\n'
-
-tap3 '-0 on a pipe, no newlines' <<'EOF'
-printf foo | rnl -0 | wc -c
->>>/3/
-EOF
-
-tap3 '-0 on a pipe, one newline' <<'EOF'
-printf 'foo\n' | rnl -0 | wc -c
->>>/3/
-EOF
-
-tap3 '-0 on a pipe, two newlines' <<'EOF'
-printf 'foo\nbar\n\n' | rnl -0 | wc -c
->>>/7/
-EOF
-
-tap3 '-0 on a pipe, three newlines' <<'EOF'
-printf 'foo\n\nbar\n\n\n' | rnl -0 | wc -c
->>>/8/
-EOF
-
-tap3 '-0 on a pipe, 9999 newlines' <<'EOF'
-( printf 'foo'; yes '' | sed 10000q ) | rnl -0 | wc -c
->>>/3/
-EOF
-
-
-
-tap3 '-0 on a file, no newlines' <<'EOF'
-printf foo > TMP; rnl -0 TMP; wc -c <TMP; rm TMP
->>>/3/
-EOF
-
-tap3 '-0 on a file, one newline' <<'EOF'
-printf 'foo\n' > TMP; rnl -0 TMP; wc -c <TMP; rm TMP
->>>/3/
-EOF
-
-tap3 '-0 on a file, two newlines' <<'EOF'
-printf 'foo\nbar\n\n' > TMP; rnl -0 TMP; wc -c <TMP; rm TMP
->>>/7/
-EOF
-
-tap3 '-0 on a file, three newlines' <<'EOF'
-printf 'foo\n\nbar\n\n\n' > TMP; rnl -0 TMP; wc -c <TMP; rm TMP
->>>/8/
-EOF
-
-tap3 '-0 on a file, 9999 newlines' <<'EOF'
-( printf 'foo'; yes '' | sed 10000q ) > TMP; rnl -0 TMP; wc -c <TMP; rm TMP
->>>/3/
-EOF
-
-tap3 '-0 on a biggish file, 9999 newlines' <<'EOF'
-( yes 'foo' | sed 10000q; yes '' | sed 10000q ) > TMP; rnl -0 TMP; wc -c <TMP; rm TMP
->>>/39999/
-EOF
diff --git a/t/1.t b/t/1.t
deleted file mode 100755
index 34611af..0000000
--- a/t/1.t
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/bin/sh
-
-export "PATH=.:$PATH"
-
-printf '1..11\n'
-printf '# error handling\n'
-
-tap3 '-1 on a pipe, no newlines' <<'EOF'
-printf foo | rnl -1
->>>/foo/
-EOF
-
-tap3 '-1 on a pipe, one newline' <<'EOF'
-printf 'foo\n' | rnl -1 | wc -c
->>>/3/
-EOF
-
-tap3 '-1 on a pipe, two newlines' <<'EOF'
-printf 'foo\nbar\n\n' | rnl -1
->>>
-foo
-bar
-EOF
-
-tap3 '-1 on a pipe, three newlines' <<'EOF'
-printf 'foo\n\nbar\n\n\n' | rnl -1
->>>
-foo
-
-bar
-
-EOF
-
-tap3 '-1 on a pipe, 9999 newlines' <<'EOF'
-( printf 'foo'; yes '' | sed 10000q ) | rnl -1 | wc -l
->>>/9999/
-EOF
-
-
-
-tap3 '-1 on a file, no newlines' <<'EOF'
-printf foo > TMP; rnl -1 TMP; cat TMP; rm TMP
->>>/foo/
-EOF
-
-tap3 '-1 on a file, one newline' <<'EOF'
-printf 'foo\n' > TMP; rnl -1 TMP; wc -c TMP; rm TMP
->>>/3/
-EOF
-
-tap3 '-1 on a file, two newlines' <<'EOF'
-printf 'foo\nbar\n\n' > TMP; rnl -1 TMP; cat TMP; rm TMP
->>>
-foo
-bar
-EOF
-
-tap3 '-1 on a file, three newlines' <<'EOF'
-printf 'foo\n\nbar\n\n\n' > TMP; rnl -1 TMP; cat TMP; rm TMP
->>>
-foo
-
-bar
-
-EOF
-
-tap3 '-1 on a file, 9999 newlines' <<'EOF'
-( printf 'foo'; yes '' | sed 10000q ) > TMP; rnl -1 TMP; wc -l TMP; rm TMP
->>>/9999/
-EOF
-
-
-tap3 '-1 on a biggish file, 9999 newlines' <<'EOF'
-( yes 'foo' | sed 10000q; yes '' | sed 10000q ) > TMP; rnl -1 TMP; wc -l < TMP; rm TMP
->>>/19999/
-EOF
diff --git a/t/a.t b/t/a.t
new file mode 100755
index 0000000..99405f7
--- /dev/null
+++ b/t/a.t
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+export "PATH=.:$PATH"
+
+printf '1..11\n'
+printf '# error handling\n'
+
+tap3 '-a on a pipe, no newlines' <<'EOF'
+printf foo | rnl -a | wc -c
+>>>/3/
+EOF
+
+tap3 '-a on a pipe, one newline' <<'EOF'
+printf 'foo\n' | rnl -a | wc -c
+>>>/3/
+EOF
+
+tap3 '-a on a pipe, two newlines' <<'EOF'
+printf 'foo\nbar\n\n' | rnl -a | wc -c
+>>>/7/
+EOF
+
+tap3 '-a on a pipe, three newlines' <<'EOF'
+printf 'foo\n\nbar\n\n\n' | rnl -a | wc -c
+>>>/8/
+EOF
+
+tap3 '-a on a pipe, 9999 newlines' <<'EOF'
+( printf 'foo'; yes '' | sed 10000q ) | rnl -a | wc -c
+>>>/3/
+EOF
+
+
+
+tap3 '-a on a file, no newlines' <<'EOF'
+printf foo > TMP; rnl -a TMP; wc -c <TMP; rm TMP
+>>>/3/
+EOF
+
+tap3 '-a on a file, one newline' <<'EOF'
+printf 'foo\n' > TMP; rnl -a TMP; wc -c <TMP; rm TMP
+>>>/3/
+EOF
+
+tap3 '-a on a file, two newlines' <<'EOF'
+printf 'foo\nbar\n\n' > TMP; rnl -a TMP; wc -c <TMP; rm TMP
+>>>/7/
+EOF
+
+tap3 '-a on a file, three newlines' <<'EOF'
+printf 'foo\n\nbar\n\n\n' > TMP; rnl -a TMP; wc -c <TMP; rm TMP
+>>>/8/
+EOF
+
+tap3 '-a on a file, 9999 newlines' <<'EOF'
+( printf 'foo'; yes '' | sed 10000q ) > TMP; rnl -a TMP; wc -c <TMP; rm TMP
+>>>/3/
+EOF
+
+tap3 '-a on a biggish file, 9999 newlines' <<'EOF'
+( yes 'foo' | sed 10000q; yes '' | sed 10000q ) > TMP; rnl -a TMP; wc -c <TMP; rm TMP
+>>>/39999/
+EOF
diff --git a/t/o.t b/t/o.t
new file mode 100755
index 0000000..78ec064
--- /dev/null
+++ b/t/o.t
@@ -0,0 +1,76 @@
+#!/bin/sh
+
+export "PATH=.:$PATH"
+
+printf '1..11\n'
+printf '# error handling\n'
+
+tap3 '-o on a pipe, no newlines' <<'EOF'
+printf foo | rnl -o
+>>>/foo/
+EOF
+
+tap3 '-o on a pipe, one newline' <<'EOF'
+printf 'foo\n' | rnl -o | wc -c
+>>>/3/
+EOF
+
+tap3 '-o on a pipe, two newlines' <<'EOF'
+printf 'foo\nbar\n\n' | rnl -o
+>>>
+foo
+bar
+EOF
+
+tap3 '-o on a pipe, three newlines' <<'EOF'
+printf 'foo\n\nbar\n\n\n' | rnl -o
+>>>
+foo
+
+bar
+
+EOF
+
+tap3 '-o on a pipe, 9999 newlines' <<'EOF'
+( printf 'foo'; yes '' | sed 10000q ) | rnl -o | wc -l
+>>>/9999/
+EOF
+
+
+
+tap3 '-o on a file, no newlines' <<'EOF'
+printf foo > TMP; rnl -o TMP; cat TMP; rm TMP
+>>>/foo/
+EOF
+
+tap3 '-o on a file, one newline' <<'EOF'
+printf 'foo\n' > TMP; rnl -o TMP; wc -c TMP; rm TMP
+>>>/3/
+EOF
+
+tap3 '-o on a file, two newlines' <<'EOF'
+printf 'foo\nbar\n\n' > TMP; rnl -o TMP; cat TMP; rm TMP
+>>>
+foo
+bar
+EOF
+
+tap3 '-o on a file, three newlines' <<'EOF'
+printf 'foo\n\nbar\n\n\n' > TMP; rnl -o TMP; cat TMP; rm TMP
+>>>
+foo
+
+bar
+
+EOF
+
+tap3 '-o on a file, 9999 newlines' <<'EOF'
+( printf 'foo'; yes '' | sed 10000q ) > TMP; rnl -o TMP; wc -l TMP; rm TMP
+>>>/9999/
+EOF
+
+
+tap3 '-o on a biggish file, 9999 newlines' <<'EOF'
+( yes 'foo' | sed 10000q; yes '' | sed 10000q ) > TMP; rnl -o TMP; wc -l < TMP; rm TMP
+>>>/19999/
+EOF