[Android] [PATCH] compile.sh: local.properties init: fix regex matching android sdk/ndk variables.

Geoffrey Métais geoffrey.metais at gmail.com
Tue Jan 30 14:05:56 CET 2018


Looks good to me.

Le sam. 27 janv. 2018 à 11:41, Robert Mourning <robedmo.git at gmail.com> a
écrit :

> From: Robert Mourning <robedmo.git at gmail.com>
>
> grep was interpreting the variables as regexes intended to
> match themselves. this could cause errors or false positives/negatives if
> the
> variables contain regex metacharacters. now the variables are escaped to
> produce regexes that will always and only match themselves.
>
> ---
>  compile.sh | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/compile.sh b/compile.sh
> index 1fa14f9ae..8cfaa957c 100755
> --- a/compile.sh
> +++ b/compile.sh
> @@ -176,14 +176,20 @@ init_local_props() {
>          echo_props > "$1"
>          return 0
>      fi
> +    # escape special chars to get regex that matches string
> +    make_regex() {
> +        echo "$1" | sed -e 's/\([[\^$.*]\)/\\\1/g' -
> +    }
> +    android_sdk_regex=`make_regex "${ANDROID_SDK}"`
> +    android_ndk_regex=`make_regex "${ANDROID_NDK}"`
>      # check for lines setting the SDK directory
>      sdk_line_start="^sdk\.dir="
>      total_sdk_count=`grep -c "${sdk_line_start}" "$1"`
> -    good_sdk_count=`grep -c "${sdk_line_start}${ANDROID_SDK}\$" "$1"`
> +    good_sdk_count=`grep -c "${sdk_line_start}${android_sdk_regex}\$"
> "$1"`
>      # check for lines setting the NDK directory
>      ndk_line_start="^ndk\.dir="
>      total_ndk_count=`grep -c "${ndk_line_start}" "$1"`
> -    good_ndk_count=`grep -c "${ndk_line_start}${ANDROID_NDK}\$" "$1"`
> +    good_ndk_count=`grep -c "${ndk_line_start}${android_ndk_regex}\$"
> "$1"`
>      # if one of each is found and both match the environment vars, no
> action needed
>      if [ "$total_sdk_count" -eq "1" -a "$good_sdk_count" -eq "1" \
>             -a "$total_ndk_count" -eq "1" -a "$good_ndk_count" -eq "1" ]
> --
> 2.15.1.windows.2
>
> _______________________________________________
> Android mailing list
> Android at videolan.org
> https://mailman.videolan.org/listinfo/android
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/android/attachments/20180130/d9e40a4f/attachment.html>


More information about the Android mailing list