commit f647e429af44253a46bde36c2ab7768ae3f27161
parent 724aaf59a63ca2ab641baf344dfa3750a72f3919
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date: Sun, 14 Feb 2021 13:13:15 -0800
Improve sman script output and separate sed(1) bits
The extracted documentation is now indented and enclosed in blank
lines to make it easier to read. This makes the sed script too long
to elegantly embed in shell script and so I moved it to sman.sed.
Diffstat:
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/modules/scripts/.local/bin/sman b/modules/scripts/.local/bin/sman
@@ -4,11 +4,10 @@
#
# sman -- simple script manual system
#
-# Write lines beginning in `#' excluding `# ?', ignoring lines
-# beginning in `#!', until a line which does not begin with `#'
-# appears.
+# Find each argument's location using which(1) and invoke sman.sed
+# on it.
for i in $*
do
- sed -Ene '/^#!/d' -e '/^#/!q' -e 's/^# ?//p' `which $i`
+ sman.sed <`which $i`
done
diff --git a/modules/scripts/.local/bin/sman.sed b/modules/scripts/.local/bin/sman.sed
@@ -0,0 +1,17 @@
+#!/usr/bin/sed -Enf
+# Copywrite 2021 Jacob R. Edwards
+# License: GPLv3
+#
+# sman.sed -- simple script manual system sed script
+#
+# Display the first comment (`#') block of a file, excluding the
+# shebang, within blank lines and indented by two spaces.
+
+1i\
+
+/^#!/d
+/^#/! { i\
+
+ q
+}
+s/^# ?/ /p