aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-02-16 01:21:45 +0100
committerDuncaen <mail@duncano.de>2017-02-16 01:21:48 +0100
commitfeb24aac3fee8cf89030ed4ad4ea09933a931536 (patch)
treeaf4e4eb0d27c6c6f1b5b0b41b228f16915324431
parent6744c75461d96634c483278766ff50a53c5226f7 (diff)
downloaddotfiles-feb24aac3fee8cf89030ed4ad4ea09933a931536.tar.gz
bin/twoman: simplify and use sed program from leah2
-rwxr-xr-xbin/twoman20
1 files changed, 5 insertions, 15 deletions
diff --git a/bin/twoman b/bin/twoman
index 6e5abd4..46ab15f 100755
--- a/bin/twoman
+++ b/bin/twoman
@@ -1,17 +1,7 @@
#!/bin/sh
-# twoman CMD... - show comment at line >2
-for x; do
- path=$(command -v "$x" 2>/dev/null)
- [ -z "$path" ] && continue
- magic="$(dd if="$path" bs=2 count=1 2>/dev/null | od -An)"
- magic=$(printf '%d' "$magic")
- case "$magic" in 8483) ;; *) continue;; esac
- awk '
-BEGIN {x=1}
-END {print "--"}
-NR>=2 && x {
- x=sub("^#[ ]?","")
- if(x){print}
-}
-' "$path"
+# twoman CMD... - show comments at the beginning of a script
+for cmd; do
+ cmd=$(command -v "$cmd" 2>/dev/null)
+ [ -z "$cmd" ] && continue
+ sed -n '1{/^[^#][^!]/q;d};0,/^$\|^[^#]/s/^# //p' $cmd
done