diff mbox series

[v2,3/5] configure: replace Perl usage with sed

Message ID 20230109181447.235989-4-marcandre.lureau@redhat.com
State New
Headers show
Series Fix win32/msys2 shader compilation & drop perl | expand

Commit Message

Marc-André Lureau Jan. 9, 2023, 6:14 p.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Let's try to reduce our Perl usage during config/build-time.

Note: this patch might be dropped if "configure: remove
backwards-compatibility code" is merged earlier.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 configure | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Peter Maydell Jan. 9, 2023, 6:42 p.m. UTC | #1
On Mon, 9 Jan 2023 at 18:16, <marcandre.lureau@redhat.com> wrote:
>
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Let's try to reduce our Perl usage during config/build-time.
>
> Note: this patch might be dropped if "configure: remove
> backwards-compatibility code" is merged earlier.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  configure | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/configure b/configure
> index 2281892657..e45acde404 100755
> --- a/configure
> +++ b/configure
> @@ -2571,11 +2571,9 @@ else
>    if test -f meson-private/cmd_line.txt; then
>      # Adjust old command line options whose type was changed
>      # Avoids having to use "setup --wipe" when Meson is upgraded
> -    perl -i -ne '
> -      s/^gettext = true$/gettext = auto/;
> -      s/^gettext = false$/gettext = disabled/;
> -      /^b_staticpic/ && next;
> -      print;' meson-private/cmd_line.txt
> +    sed -i.bak 's/^gettext = true/gettext = auto/g' -e \
> +      's/^gettext = false/gettext = disabled/g' -e \
> +      '/^b_staticpic/d' meson-private/cmd_line.txt

This doesn't work on macos sed, because POSIX sed allows

 sed command file
or
 sed -e command -e command file
but not
 sed command -e command file

The fix is easy, prefix the first command with '-e'.

-i is not POSIX sed, but luckily the BSD sed implements it.

The two gettext matches have lost the trailing '$' in the regex.

thanks
-- PMM
diff mbox series

Patch

diff --git a/configure b/configure
index 2281892657..e45acde404 100755
--- a/configure
+++ b/configure
@@ -2571,11 +2571,9 @@  else
   if test -f meson-private/cmd_line.txt; then
     # Adjust old command line options whose type was changed
     # Avoids having to use "setup --wipe" when Meson is upgraded
-    perl -i -ne '
-      s/^gettext = true$/gettext = auto/;
-      s/^gettext = false$/gettext = disabled/;
-      /^b_staticpic/ && next;
-      print;' meson-private/cmd_line.txt
+    sed -i.bak 's/^gettext = true/gettext = auto/g' -e \
+      's/^gettext = false/gettext = disabled/g' -e \
+      '/^b_staticpic/d' meson-private/cmd_line.txt
   fi
 fi