diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-05-12 19:23:16 -0400 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-05-12 19:23:16 -0400 |
commit | 272f57b2a4d9f2c8d5ac3c46962f25c55dfbb270 (patch) | |
tree | 90055d8d7e394ae5377200ee2ec00afa4b861f0b /jh-list-commands.sh | |
parent | b2c326dc625c0ee7cdfb5763b036db6893db9efd (diff) |
simplify by moving usage() into jh-help, jh no longer needs to be included
Diffstat (limited to 'jh-list-commands.sh')
-rw-r--r-- | jh-list-commands.sh | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/jh-list-commands.sh b/jh-list-commands.sh index 143f6e7..66ce5aa 100644 --- a/jh-list-commands.sh +++ b/jh-list-commands.sh @@ -1,13 +1,17 @@ #!/bin/bash -. jh if [[ $# > 0 ]]; then - usage + jh-help $0 >>/dev/stderr exit 1 fi -for cmd_help in "$JH_PATH"/*.help.txt; do - cmd=`echo "$cmd_help"|sed -r 's|.*/jh-(.*)\.help\.txt$|\1|'` +stem=jh + +find ${PATH//:/ } -type f -name "$stem-*.help.txt" 2>/dev/null | +while read cmd_help; do + cmd=$cmd_help + cmd=${cmd%.help.txt} + cmd=${cmd##*/$stem-} help=`sed -n 2p "$cmd_help"` - printf "%-20s %s\n" "$cmd" "$help" -done + printf '%-20s %s\n' "$cmd" "$help" +done | sort |