summaryrefslogtreecommitdiff
path: root/lsinitramfs
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2019-02-06 03:42:12 +0000
committerBen Hutchings <ben@decadent.org.uk>2019-02-06 03:43:02 +0000
commit908bd7dc3528633baafa8ffbf97411f34bbd5c84 (patch)
tree872deec34f353de3cfcde9716efee808b6e28420 /lsinitramfs
parent45f4d152b59c09fd37fad497e0b5c09e61c321b2 (diff)
lsinitramfs, mkinitramfs, unmkinitramfs: Show usage if getopt fails
We currently show an odd warning about "non-GNU getopt", which doesn't make any sense: 1. It appears in case of a fatal error, thus a mere warning is not appropriate. 2. It appears in case of *any* error from getopt(1), which will have already issued its own error message. 3. getopt(1) is normally provided by util-linux, not a GNU package. 4. There doesn't seem to be any alternate implementation in Debian. This reverts commit e967b03f31e784e8a8a6189c5de5d7b0e6b9bb56, and the additional copy of this warning in unmkinitramfs. Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'lsinitramfs')
-rwxr-xr-xlsinitramfs12
1 files changed, 7 insertions, 5 deletions
diff --git a/lsinitramfs b/lsinitramfs
index 03ee517..c106697 100755
--- a/lsinitramfs
+++ b/lsinitramfs
@@ -16,17 +16,19 @@ See lsinitramfs(8) for further details.
EOF
}
-if [ "$#" -eq 0 ] ; then
+usage_error()
+{
usage >&2
exit 2
+}
+
+if [ "$#" -eq 0 ] ; then
+ usage_error
fi
umi_opts="--list"
-OPTIONS=$(getopt -o hl --long help,long -n "$0" -- "$@")
-# Check for non-GNU getopt
-# shellcheck disable=SC2181
-if [ $? != 0 ] ; then echo "W: non-GNU getopt" >&2 ; exit 2 ; fi
+OPTIONS=$(getopt -o hl --long help,long -n "$0" -- "$@") || usage_error
eval set -- "$OPTIONS"