Created
May 25, 2012 14:29
-
-
Save OBdA/2788435 to your computer and use it in GitHub Desktop.
Inline manual in shell scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/sh | |
| __check_for_help() | |
| { | |
| set +u # disable 'nounset' because positional parameters may be unset | |
| # check $0 against the file name because of scripts sourcing shell libraries | |
| # with inline documentation | |
| test $(basename $0) = 'libUMI.sh' -a \( '--help' = "$1" -o '-h' = "$1" \) \ | |
| && exec sed -n '/^#--/ {s/^#--//; p}' $0 | less -+S -FRX && exit 1 | |
| } | |
| __check_for_help "$@" | |
| #-- | |
| #--NAME | |
| #-- blurb | |
| #-- | |
| #--SYNOPSIS | |
| #-- ./blurb --help | |
| #-- ./blurb -h | |
| #-- | |
| #EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Gist demonstrates how to include documentation into shell scripts.