diff options
| author | maximilian attems <maks@debian.org> | 2010-06-18 11:36:26 +0200 | 
|---|---|---|
| committer | maximilian attems <maks@debian.org> | 2010-06-18 11:50:38 +0200 | 
| commit | 2f3eb88faf2ac21036d4b33e5f44c9be076a635a (patch) | |
| tree | 095f988d73c02a61bcd91d20139f3c4e8837087c /lsinitramfs | |
| parent | 6147641d9129db51421ef0706972e21ceb36c801 (diff) | |
| download | initramfs-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>
Diffstat (limited to 'lsinitramfs')
| -rwxr-xr-x | lsinitramfs | 39 | 
1 files changed, 31 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 | 
