[PATCH 3/5] xen/tools: fix grep reporting 'illegal byte sequence' in check-endbr.sh

Roger Pau Monne posted 5 patches 2 months ago
There is a newer version of this series
[PATCH 3/5] xen/tools: fix grep reporting 'illegal byte sequence' in check-endbr.sh
Posted by Roger Pau Monne 2 months ago
On macOS the default encoding is UTF-8.  The binary encoding used by the
grep matching pattern is not valid when processed as UTF-8.  Switch the
local to C just for the grep invocation to use the binary match pattern
correctly.

Suggested-by: Bertrand Marquis <bertrand.marquis@arm.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/tools/check-endbr.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/xen/tools/check-endbr.sh b/xen/tools/check-endbr.sh
index 383d7e710a53..0be9986dd356 100755
--- a/xen/tools/check-endbr.sh
+++ b/xen/tools/check-endbr.sh
@@ -109,8 +109,9 @@ if $perl_re
 then
     LC_ALL=C grep -aobP '\xf3\x0f\x1e(\xfa|\xfb)|\x66\x0f\x1f\x01' $TEXT_BIN
 else
-    grep -aob -e "$(printf '\363\17\36\372')" -e "$(printf '\363\17\36\373')" \
-         -e "$(printf '\146\17\37\1')" $TEXT_BIN
+    LC_ALL=C grep -aob -e "$(printf '\363\17\36\372')" \
+                       -e "$(printf '\363\17\36\373')" \
+                       -e "$(printf '\146\17\37\1')" $TEXT_BIN
 fi | $AWK -F':' '{printf "%s%07x\n", "'$vma_hi'", int('$((0x$vma_lo))') + $1}' > $ALL
 
 # Wait for $VALID to become complete
-- 
2.51.0


Re: [PATCH 3/5] xen/tools: fix grep reporting 'illegal byte sequence' in check-endbr.sh
Posted by Bertrand Marquis 2 months ago
Hi Roger,

> On 11 Feb 2026, at 11:46, Roger Pau Monne <roger.pau@citrix.com> wrote:
> 
> On macOS the default encoding is UTF-8.  The binary encoding used by the
> grep matching pattern is not valid when processed as UTF-8.  Switch the
> local to C just for the grep invocation to use the binary match pattern
> correctly.
> 
> Suggested-by: Bertrand Marquis <bertrand.marquis@arm.com>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Works and makes sense.

Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

Cheers
Bertrand

> ---
> xen/tools/check-endbr.sh | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/tools/check-endbr.sh b/xen/tools/check-endbr.sh
> index 383d7e710a53..0be9986dd356 100755
> --- a/xen/tools/check-endbr.sh
> +++ b/xen/tools/check-endbr.sh
> @@ -109,8 +109,9 @@ if $perl_re
> then
>     LC_ALL=C grep -aobP '\xf3\x0f\x1e(\xfa|\xfb)|\x66\x0f\x1f\x01' $TEXT_BIN
> else
> -    grep -aob -e "$(printf '\363\17\36\372')" -e "$(printf '\363\17\36\373')" \
> -         -e "$(printf '\146\17\37\1')" $TEXT_BIN
> +    LC_ALL=C grep -aob -e "$(printf '\363\17\36\372')" \
> +                       -e "$(printf '\363\17\36\373')" \
> +                       -e "$(printf '\146\17\37\1')" $TEXT_BIN
> fi | $AWK -F':' '{printf "%s%07x\n", "'$vma_hi'", int('$((0x$vma_lo))') + $1}' > $ALL
> 
> # Wait for $VALID to become complete
> -- 
> 2.51.0
>