Allow outputting both flags and arrays for arg_i and arg_x

This should later probably be split so we have dedicated varnames for the different types, as we're now making the template uglier just to accomodate our tests
This commit is contained in:
Kevin van Zonneveld 2019-10-29 09:57:59 +01:00
parent 685442bbcc
commit b8a4aba3c2

16
main.sh
View File

@ -404,16 +404,26 @@ info "arg_f: ${arg_f}"
info "arg_d: ${arg_d}"
info "arg_v: ${arg_v}"
info "arg_h: ${arg_h}"
if [[ -n "${arg_i:-}" ]]; then
info "arg_i: ${#arg_i[@]}"
# shellcheck disable=SC2015
if [[ -n "${arg_i:-}" ]] && declare -p arg_i 2> /dev/null | grep -q '^declare \-a'; then
for input_file in "${arg_i[@]}"; do
info " - ${input_file}"
done
elif [[ -n "${arg_i:-}" ]]; then
info "arg_i: ${arg_i}"
else
info "arg_i: 0"
fi
# shellcheck disable=SC2015
[[ -n "${arg_x:-}" ]] && info "arg_x: ${#arg_x[@]}" || info "arg_x: 0"
if [[ -n "${arg_x:-}" ]] && declare -p arg_x 2> /dev/null | grep -q '^declare \-a'; then
info "arg_x: ${#arg_x[@]}"
elif [[ -n "${arg_x:-}" ]]; then
info "arg_x: ${arg_x}"
else
info "arg_x: 0"
fi
info "$(echo -e "multiple lines example - line #1\\nmultiple lines example - line #2\\nimagine logging the output of 'ls -al /path/'")"