Created
July 24, 2016 21:14
-
-
Save jrhaberstroh/3e541ce3b8996a9be407dd28fbf096cb to your computer and use it in GitHub Desktop.
This file contains 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/bash | |
help() | |
{ | |
sed --silent -e '/^: <<.*HELPDOC/,/^HELPDOC$/p' ${BASH_SOURCE[0]} | tail -n+2 | head -n-1 | |
} | |
SRCDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | |
: <<'HELPDOC' | |
================== | |
newbash | |
================== | |
Creates a new bash document with my common bash options. | |
It makes me happy to do this. | |
usage: | |
newbash $1 Creates a new file ($1) with header and argparse set up | |
HELPDOC | |
trap help EXIT | |
: <<VARCHECK | |
${1?} | |
VARCHECK | |
trap - EXIT | |
cat <<'NEWBASH' > $1 | |
#!/bin/bash | |
set -o nounset | |
set -o errexit | |
SRCDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | |
NEWBASH | |
chmod +x $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment