From fc81f7f5f0da28d3f7b89bf57c8ddd4f8fd7d4f2 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Wed, 6 Feb 2019 01:47:03 +0000 Subject: [PATCH] mkinitramfs: Support -h and --help options Signed-off-by: Ben Hutchings --- mkinitramfs | 15 ++++++++++++--- mkinitramfs.8 | 7 ++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/mkinitramfs b/mkinitramfs index 3c3eb6c..4a4a4ea 100755 --- a/mkinitramfs +++ b/mkinitramfs @@ -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" diff --git a/mkinitramfs.8 b/mkinitramfs.8 index ced5d18..b31b542 100644 --- a/mkinitramfs.8 +++ b/mkinitramfs.8 @@ -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