summaryrefslogtreecommitdiffstats
path: root/lsinitcpio
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2016-07-12 04:05:45 +0200
committerDave Reisner <dreisner@archlinux.org>2016-07-12 14:00:49 +0200
commitf5129add0eb16c9511c9cb80433fb4568f1e2703 (patch)
tree355faf43432d46cdb7aa829e1300987cf47e3798 /lsinitcpio
parentb9308a5296fc0dc8da78cd6f02a5af9c38f0a044 (diff)
downloadmkinitcpio-f5129add0eb16c9511c9cb80433fb4568f1e2703.tar.gz
mkinitcpio-f5129add0eb16c9511c9cb80433fb4568f1e2703.tar.xz
use an associative array to build bsdcpio options
This prevents having unquoted expansion in the bsdcpio commandline
Diffstat (limited to 'lsinitcpio')
-rwxr-xr-xlsinitcpio37
1 files changed, 26 insertions, 11 deletions
diff --git a/lsinitcpio b/lsinitcpio
index f54fa25..faad720 100755
--- a/lsinitcpio
+++ b/lsinitcpio
@@ -6,9 +6,15 @@
shopt -s extglob
_list='--list'
-_optcolor=1 _optverbose=
+_optcolor=1
_f_functions=functions
+declare -A bsdcpio_options=(
+ [list]='--list'
+ [input]='-i'
+ [quiet]='--quiet'
+)
+
usage() {
cat<<USAGE
lsinitcpio %VERSION%
@@ -237,26 +243,35 @@ unset _opt_short _opt_long OPTRET
while :; do
case $1 in
-a|--analyze)
- _optanalyze=1 ;;
+ _optanalyze=1
+ ;;
-c|--config)
- _optshowconfig=1 ;;
+ _optshowconfig=1
+ ;;
-h|--help)
usage
- exit 0 ;;
+ exit 0
+ ;;
-l|--list)
- _optlistcontents=1 ;;
+ _optlistcontents=1
+ ;;
-n|--nocolor)
- _optcolor=0 ;;
+ _optcolor=0
+ ;;
-V|--version)
version
- exit 0 ;;
+ exit 0
+ ;;
-v|--verbose)
- _optverbose='--verbose' ;;
+ bsdcpio_options['verbose']='--verbose'
+ ;;
-x|--extract)
- unset _list ;;
+ unset 'bsdcpio_options[list]'
+ ;;
--)
shift
- break 2 ;;
+ break 2
+ ;;
esac
shift
done
@@ -287,7 +302,7 @@ elif (( _optshowconfig )); then
decomp "$_image" | bsdtar xOf - buildconfig 2>/dev/null ||
die 'Failed to extract config from image (mkinitcpio too old?)'
else
- decomp "$_image" | bsdcpio -i --quiet $_optverbose $_list
+ decomp "$_image" | bsdcpio "${bsdcpio_options[@]}"
fi
# vim: set ft=sh ts=4 sw=4 et: