[PATCH] awk: fix handling of literal backslashes in replacement

Yao Zi ziyao at disroot.org
Thu Apr 17 06:01:53 UTC 2025


On Mon, Dec 09, 2024 at 08:07:22AM +0000, Yao Zi wrote:
> 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.

Ping again on this patch, thanks for your time and review.

> Best regards,
> Yao Zi

Regards,
Yao Zi

> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> https://lists.busybox.net/mailman/listinfo/busybox


More information about the busybox mailing list