Subject: bug#47281: sed: problem with hex replace a literal '$'

From: Bastian Bittorf <[email-masked]>
Date: Sun, 21 Mar 2021 14:53:58 +0000

> Hello,
>
> the behavior you are describing is documented here:
> https://www.gnu.org/software/sed/manual/sed.html#Escaping-Precedence
>
> If you want to produce a basic regular
> expression given a string to be matched 
> literally, precede any of $*.[\]^ with \
> Likewise, if you are using hex escapes (\xHH),
> precede any of \x24 \x2a \x2e \x5b \x5c \x5d \x5e with \x5c

Hi Nora,

thanks for your help suggesting the escaping.

I understand, that this behaviour is valid and not a bug.
Maybe you can post this to the Mailingslist as well,
i'am not subscribed there.

Indeed this is really awkward, but I have to
accept that and use now something like that:

#!/bin/sh
#
# [...]
#
# case "$hex" in
#   24|2a|2e|5b|5c|5d|5e)
#     hex="5c\x$hex"
#   ;;
# esac

see:
https://github.com/bittorf/kritis-linux/commit/d3cc6c84a6c021ae2f7e9351f9f4ef0fc7098c0b

Thanks again & bye,
Bastian Bittorf