[PATCH] awk: fix handling of literal backslashes in replacement
Yao Zi
ziyao at disroot.org
Mon Dec 9 08:07:22 UTC 2024
On Thu, Nov 14, 2024 at 11:11:50AM +0000, Yao Zi wrote:
> According to POSIX standard, a backslash in the replacement of sub()
> should be treated as a literal backslash if it is not preceded by a '&'
> or another backslash. But busybox awk skips it unconditionally,
> regardless of the following character. For example,
>
> $ echo "abc" | busybox awk 'sub(/abc/, "\\d")'
> d
>
> where \d is expected here. This is known to break rsync's documentation
> converter.
>
> Let's check the next character before skipping the backslash, following
> POSIX standard and behavior of GNU awk.
>
> Link: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html
> Link: https://github.com/RsyncProject/rsync/blob/62bb9bba022ce6a29f8c92307d5569c338b2f711/help-from-md.awk#L22
> Fixes: 5f84c5633 ("awk: fix backslash handling in sub() builtins")
> Signed-off-by: Yao Zi <ziyao at disroot.org>
Ping on this patch, thanks for your time and review.
Best regards,
Yao Zi
More information about the busybox
mailing list