[pacman-dev] [PATCH 07/11] makepkg: less code repetition when sanitizing variable contents
Allan McRae
allan at archlinux.org
Thu Jun 17 09:22:26 EDT 2010
On 17/06/10 22:44, Andres P wrote:
> During check_sanity, use regex and abstract the series of variable checks into
> a list.
>
> Signed-off-by: Andres P<aepd87 at gmail.com>
> ---
> scripts/makepkg.sh.in | 70 +++++++++++++++++++-----------------------------
> 1 files changed, 28 insertions(+), 42 deletions(-)
>
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index 23e3b36..991ad0f 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -1161,6 +1161,19 @@ install_package() {
> fi
> }
>
> +var_lint() {
> + local pattern="$1"
> + local directive="$2"
> + shift 2
> +
> + local i
> + for i; do
> + [[ $i =~ $pattern ]] || continue
> + error "$(gettext "'%s' is an invalid value for %s")" "$i" "$directive"
> + return 1
> + done
> +}
I am against this as the error messages are no longer informative.
Allan
More information about the pacman-dev
mailing list