[PATCH v2] env: Avoid using GNU features in awk

Tom Rini trini at konsulko.com
Sat Nov 20 16:22:55 CET 2021


On Sat, Nov 20, 2021 at 08:20:05AM -0700, Simon Glass wrote:

> GNU has a very useful third argument to match() but this is not supported
> in the POSIX awk. It is a great shame.
> 
> Update the code to cope.
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
> 
> Changes in v2:
> - Fix the has_var match() that had left-over test code
> 
>  scripts/env2string.awk | 23 +++++++++++++++--------
>  1 file changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/scripts/env2string.awk b/scripts/env2string.awk
> index 57d0fc8f3ba..e758738df07 100644
> --- a/scripts/env2string.awk
> +++ b/scripts/env2string.awk
> @@ -24,26 +24,33 @@ NF {
>  	# Quote quotes
>  	gsub("\"", "\\\"")
>  
> +	# Avoid using the non-POSIX third parameter to match() which is very
> +	# inconvenient
> +	has_var = match($0, "^([^ \t=][^ =]*)=(.*)$")

We need our scripts to be POSIX compliant, that's a feature not a bug
nor something to talk down at.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20211120/5cc43404/attachment.sig>


More information about the U-Boot mailing list