Signed-off-by: Andres P <aepd87@gmail.com> --- Without a function, this would look like: local fmt="= %s\n" [[ $license ]] && printf "license $fmt" "${license[@]}" [[ $replaces ]] && printf "replaces $fmt" "${replaces[@]}" [[ $groups ]] && printf "group $fmt" "${groups[@]}" [[ $depends ]] && printf "depend $fmt" "${depends[@]}" [[ $optdepend ]] && printf "optdepend $fmt" "${optdepends[@]}" [[ $conflict ]] && printf "conflict $fmt" "${conflicts[@]}" [[ $provides ]] && printf "provides $fmt" "${provides[@]}" [[ $backup ]] && printf "backup $fmt" "${backup[@]}" ... scripts/makepkg.sh.in | 38 +++++++++++++------------------------- 1 files changed, 13 insertions(+), 25 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 7f27361..18bbb3f 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -893,6 +893,10 @@ tidy_install() { fi } +multiopt() { + [[ $2 ]] && printf "$1 = %s\n" "${@:1}" +} + write_pkginfo() { local builddate=$(date -u "+%s") if [[ -n $PACKAGER ]]; then @@ -922,31 +926,15 @@ write_pkginfo() { echo "force = true" fi - local it - for it in "${license[@]}"; do - echo "license = $it" - done - for it in "${replaces[@]}"; do - echo "replaces = $it" - done - for it in "${groups[@]}"; do - echo "group = $it" - done - for it in "${depends[@]}"; do - echo "depend = $it" - done - for it in "${optdepends[@]}"; do - echo "optdepend = $it" - done - for it in "${conflicts[@]}"; do - echo "conflict = $it" - done - for it in "${provides[@]}"; do - echo "provides = $it" - done - for it in "${backup[@]}"; do - echo "backup = $it" - done + multiopt "license" "${license[@]}" + multiopt "replaces" "${replaces[@]}" + multiopt "group" "${groups[@]}" + multiopt "depend" "${depends[@]}" + multiopt "optdepend" "${optdepends[@]}" + multiopt "conflict" "${conflicts[@]}" + multiopt "provides" "${provides[@]}" + multiopt "backup" "${backup[@]}" + for it in "${packaging_options[@]}"; do local ret="$(check_option $it)" if [[ $ret != "?" ]]; then -- 1.7.1