mkinitramfs: Support -h and --help options

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
This commit is contained in:
Ben Hutchings 2019-02-06 01:47:03 +00:00
parent c80032179c
commit fc81f7f5f0
2 changed files with 18 additions and 4 deletions

View File

@ -13,7 +13,7 @@ export BUSYBOXDIR
usage()
{
cat >&2 << EOF
cat << EOF
Usage: ${0} [OPTION]... -o outfile [version]
@ -26,10 +26,15 @@ Options:
See mkinitramfs(8) for further details.
EOF
}
usage_error()
{
usage >&2
exit 2
}
OPTIONS=$(getopt -o c:d:ko:r:v -n "$0" -- "$@")
OPTIONS=$(getopt -o c:d:hko:r:v --long help -n "$0" -- "$@")
# Check for non-GNU getopt
# shellcheck disable=SC2181
@ -51,6 +56,10 @@ while true; do
exit 1
fi
;;
-h|--help)
usage
exit 0
;;
-o)
outfile="$2"
shift 2
@ -128,7 +137,7 @@ if [ -n "${UMASK:-}" ]; then
fi
if [ -z "${outfile}" ]; then
usage
usage_error
fi
touch "$outfile"

View File

@ -16,6 +16,8 @@ mkinitramfs \- low-level tool for generating an initramfs image
.IR root ]
.RB [ \-v ]
.RI [ version ]
.br
.BR mkinitramfs " " -h
.SH DESCRIPTION
The
@ -49,7 +51,6 @@ setting in
\fB\-d \fI confdir
Set an alternate configuration directory.
.TP
.TP
\fB\-k
Keep the temporary directory used to make the image.
@ -75,6 +76,10 @@ Set the verbose mode output.
Set the kernel version of the initramfs image
(defaults to the running kernel).
.TP
\fB\-h\fR, \fB\-\-help\fR
Display usage information and exit.
.SH ENVIRONMENT
.B mkinitramfs
honours the