summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormaximilian attems <maks@debian.org>2010-06-18 11:36:26 +0200
committermaximilian attems <maks@debian.org>2010-06-18 11:50:38 +0200
commit2f3eb88faf2ac21036d4b33e5f44c9be076a635a (patch)
tree095f988d73c02a61bcd91d20139f3c4e8837087c
parent6147641d9129db51421ef0706972e21ceb36c801 (diff)
downloadinitramfs-tools-2f3eb88faf2ac21036d4b33e5f44c9be076a635a.tar.gz
initramfs-tools-2f3eb88faf2ac21036d4b33e5f44c9be076a635a.zip
lsinitramfs: use getopt for -l option
only pass verbose to cpio if invoked with -l or --long. add minimal hints to manpage. Signed-off-by: maximilian attems <maks@debian.org>
-rwxr-xr-xlsinitramfs39
-rw-r--r--lsinitramfs.82
2 files changed, 33 insertions, 8 deletions
diff --git a/lsinitramfs b/lsinitramfs
index e395de8..3fcc50c 100755
--- a/lsinitramfs
+++ b/lsinitramfs
@@ -12,17 +12,40 @@ if [ "$#" -eq 0 ] ; then
exit 1
fi
-if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
- usage
- exit 0
-fi
+cpio_args="--extract --quiet --list"
+
+OPTIONS=`getopt -o hl --long help,long -n "$0" -- "$@"`
+# Check for non-GNU getopt
+if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
+
+eval set -- "$OPTIONS"
+
+while true; do
+ case "$1" in
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ -l|--long)
+ cpio_args="${cpio_args:+${cpio_args} --verbose}"
+ shift
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ echo "Internal error!" >&2
+ exit 1
+ esac
+done
-for i in "$@" ; do
- if ! [ -r "$i" ] ; then
+for initramfs in "$@" ; do
+ if ! [ -r "${initramfs}" ] ; then
echo "Specified file could not be read." >&2
exit 1
else
- echo "$i"
- zcat "$i" | cpio --extract --verbose --quiet --list
+ echo "${initramfs}"
+ zcat "${initramfs}" | cpio ${cpio_args}
fi
done
diff --git a/lsinitramfs.8 b/lsinitramfs.8
index bb809ae..c1aa897 100644
--- a/lsinitramfs.8
+++ b/lsinitramfs.8
@@ -5,7 +5,9 @@ lsinitramfs \- list content of an initramfs image
.SH SYNOPSIS
.B lsinitramfs
+.RB [ \-l ]
.IR initramfsfile
+.RB [ \-h ]
.SH DESCRIPTION
The