GNU bug report logs - #47281
sed: problem with hex replace a literal '$'

Previous Next

Package: sed;

Reported by: Bastian Bittorf <bb <at> npl.de>

Date: Sat, 20 Mar 2021 13:51:01 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Bastian Bittorf <bb <at> npl.de>
To: 47281 <at> debbugs.gnu.org
Cc: nplatiel <at> gmx.us
Subject: bug#47281: sed: problem with hex replace a literal '$'
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




This bug report was last modified 4 years and 86 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.