36 lines
571 B
Bash
Executable File
36 lines
571 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -eo pipefail
|
|
|
|
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
|
|
cat <<EOF
|
|
Usage: $(basename "$0") [-h] <script>
|
|
|
|
Create a new bash script with boilerplate.
|
|
|
|
Options:
|
|
-h, --help Show this help message
|
|
|
|
Arguments:
|
|
script Script filename to create
|
|
|
|
EOF
|
|
exit 0
|
|
fi
|
|
|
|
if [ ! $# -eq 1 ]; then
|
|
echo 'mksh takes one argument' 1>&2
|
|
exit 1
|
|
elif [ -e "$1" ]; then
|
|
echo "$1 already exists" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
{
|
|
echo '#!/usr/bin/env bash'
|
|
echo 'set -eo pipefail'
|
|
echo
|
|
} > "$1"
|
|
|
|
chmod u+x "$1"
|
|
exec "$EDITOR" "$1"
|