diff --git a/mender-convert-extract b/mender-convert-extract index 708d745..7713b41 100755 --- a/mender-convert-extract +++ b/mender-convert-extract @@ -19,6 +19,8 @@ echo "Running $(basename $0): $@" source modules/bootstrap.sh source modules/disk.sh +declare -a configs + disk_image="" while (( "$#" )); do case "$1" in @@ -27,7 +29,7 @@ while (( "$#" )); do shift 2 ;; -c | --config) - configs+="${2}" + configs+=("${2}") shift 2 ;; -d | --disk-image) @@ -50,7 +52,11 @@ if [ ! -e ${disk_image} ]; then log_fatal "File not found: ${disk_image}" fi -source modules/config.sh "${configs[@]}" +# Note the use of %q formatting here. This is a bash feature to add +# proper quoting to the strings so that spaces and special characters +# will be treated properly. Primarily for supporting spaces in +# pathnames and avoid splitting those into multiple parameters. +source modules/config.sh $(printf "%q " "${configs[@]}") MKFS_VFAT="/usr/bin/mkfs.vfat" if [ ! -f ${MKFS_VFAT} ]; then diff --git a/mender-convert-modify b/mender-convert-modify index 0ca16e7..b352e81 100755 --- a/mender-convert-modify +++ b/mender-convert-modify @@ -39,6 +39,8 @@ source modules/bootstrap.sh source modules/disk.sh source modules/probe.sh +declare -a configs + while (( "$#" )); do case "$1" in -o | --overlay) @@ -46,7 +48,7 @@ while (( "$#" )); do shift 2 ;; -c | --config) - configs+="${2}" + configs+=("${2}") shift 2 ;; -d | --disk-image) @@ -59,7 +61,11 @@ while (( "$#" )); do esac done -source modules/config.sh "${configs[@]}" +# Note the use of %q formatting here. This is a bash feature to add +# proper quoting to the strings so that spaces and special characters +# will be treated properly. Primarily for supporting spaces in +# pathnames and avoid splitting those into multiple parameters. +source modules/config.sh $(printf "%q " "${configs[@]}") boot_part=$(disk_boot_part) root_part=$(disk_root_part) diff --git a/mender-convert-package b/mender-convert-package index f8e968e..9d3489f 100755 --- a/mender-convert-package +++ b/mender-convert-package @@ -38,6 +38,8 @@ echo "Running $(basename $0): $@" source modules/bootstrap.sh source modules/disk.sh +declare -a configs + while (( "$#" )); do case "$1" in -o | --overlay) @@ -45,7 +47,7 @@ while (( "$#" )); do shift 2 ;; -c | --config) - configs+="${2}" + configs+=("${2}") shift 2 ;; -d | --disk-image) @@ -58,7 +60,11 @@ while (( "$#" )); do esac done -source modules/config.sh "${configs[@]}" +# Note the use of %q formatting here. This is a bash feature to add +# proper quoting to the strings so that spaces and special characters +# will be treated properly. Primarily for supporting spaces in +# pathnames and avoid splitting those into multiple parameters. +source modules/config.sh $(printf "%q " "${configs[@]}") PARTED="/usr/bin/parted" if [ ! -f ${PARTED} ]; then diff --git a/modules/config.sh b/modules/config.sh index 82e6c5e..ea653cb 100644 --- a/modules/config.sh +++ b/modules/config.sh @@ -14,7 +14,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -for config in configs/mender_convert_config "$@"; do - log_info "Using configuration file: ${config}" - source ${config} +# Read in the array of config files to process +read -a configs <<< "${@}" +configs=( "configs/mender_convert_config" "${configs[@]}" ) +for config in "${configs[@]}"; do + log_info "Using configuration file: ${config}" + source "${config}" done