On 13/06/18 11:40, morganamilo wrote:
> Error if the arch array contains any and any other values. This also
> fixes a bug where the check for `$arch == 'any'` which only evaluated
> the first value in the array, meaning the rest of the values would not
> be linted.
> 
> Signed-off-by: morganamilo <morganam...@gmail.com>
> ---

Please append a version of you patch in the subject line. e.g.
[PATCH 7/7 v3]

>  scripts/libmakepkg/lint_pkgbuild/arch.sh.in | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in 
> b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
> index f2c80c73..f3dd8ee6 100644
> --- a/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
> +++ b/scripts/libmakepkg/lint_pkgbuild/arch.sh.in
> @@ -38,11 +38,16 @@ lint_arch() {
>               return 1
>       fi
>  
> -     if [[ $arch == 'any' ]]; then
> +     if [[ $arch == 'any' ]] && (( ${#arch[@]} == 1 )); then
>               return 0
>       fi
>  

I'm still not happy with this patch.  Why not just explicitly check that
"any" is specified on its own, rather than a check here and one in the
following loop.

if in_array "any" "${arch[@]}"; then
        if (( ${#arch[@]} == 1 )); then
                return 0;
        else
                error "$(gettext "...")"
                return 1;
        fi
fi

Also, "any" should be %s in the error string as so it is not translated.
 A better error message is:

$(gettext "Can not use '%s' architecture with other architectures")" "any"



>       for a in "${arch[@]}"; do
> +             if [[ $a == 'any' ]]; then
> +                     error "$(gettext "any can not be used with other 
> architectures")"
> +                     ret=1
> +             fi
> +
>               if [[ $a = *[![:alnum:]_]* ]]; then
>                       error "$(gettext "%s contains invalid characters: 
> '%s'")" \
>                                       'arch' "${a//[[:alnum:]_]}"
> 

Reply via email to