aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-03 21:21:52 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-03 21:21:52 +1200
commit86b3532b4584355b85998fddf1db0d995109ff12 (patch)
treeea7df77f73c1567419906999d9001b3ba81afbd6
parentCorrect stbl(1) manual page (diff)
downloaddotfiles-86b3532b4584355b85998fddf1db0d995109ff12.tar.gz
dotfiles-86b3532b4584355b85998fddf1db0d995109ff12.zip
Add stws(1)
-rw-r--r--README.markdown2
-rwxr-xr-xbin/stws11
-rw-r--r--man/man1/stws.111
3 files changed, 24 insertions, 0 deletions
diff --git a/README.markdown b/README.markdown
index 95153945..e8efad5f 100644
--- a/README.markdown
+++ b/README.markdown
@@ -353,6 +353,8 @@ Installed by the `install-bin` target:
* `shb(1)` attempts to build shebang lines for scripts from `$PATH`.
* `spr(1)` posts its input to the sprunge.us pastebin.
* `stbl(1)` strips a trailing blank line from the files in its arguments.
+* `stws(1)` strips trailing spaces from the ends of lines of the files in its
+ arguments.
* `sue(8)` execs `sudoedit(8)` as the owner of all the file arguments given,
perhaps in cases where you may not necessarily have `root` `sudo(8)`
privileges.
diff --git a/bin/stws b/bin/stws
new file mode 100755
index 00000000..1514a979
--- /dev/null
+++ b/bin/stws
@@ -0,0 +1,11 @@
+#!/bin/sh
+# Strip trailing spaces on one or more files
+if [ "$#" -eq 0 ] ; then
+ printf >&2 'tstf: Need filenames\n'
+fi
+for fn ; do
+ ed -s -- "$fn" <<'EOF'
+g/ *$/ s/ *$//
+w
+EOF
+done
diff --git a/man/man1/stws.1 b/man/man1/stws.1
new file mode 100644
index 00000000..730d42aa
--- /dev/null
+++ b/man/man1/stws.1
@@ -0,0 +1,11 @@
+.TH STWS 1 "August 2016" "Manual page for stws"
+.SH NAME
+.B stws
+\- strip trailing spaces from files
+.SH USAGE
+.B stws FILE1 [FILE2 ...]
+.SH DESCRIPTION
+Applies ed(1) to remove all trailing spaces at the end of lines, if present,
+from each of the given files.
+.SH AUTHOR
+Tom Ryder <tom@sanctum.geek.nz>