[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gawk] Is \x24 the literal dollar character?
From: |
Kozics Peter (FM) |
Subject: |
[bug-gawk] Is \x24 the literal dollar character? |
Date: |
Sat, 12 Oct 2019 16:46:56 +0200 |
User-agent: |
Evolution 3.32.4 (3.32.4-1.fc30) |
Dear,
(1)
this matches:
$ gawk '/\$Id: .*\$/ {print}' <<< '$Id: rcsid$'
$Id: rcsid$
(2)
I expected that this would match as well, but it didn't:
$ gawk '/\x24Id: .*\x24/ {print}' <<< '$Id: rcsid$'
The expectation was based on gawk manual section 3.2: \x24 should be
the literal dollar character, not the dollar metacharacter.
(3)
Now, let's go on, this does not match either:
$ gawk '/\\x24Id: .*\\x24/ {print}' <<< '$Id: rcsid$'
(4)
And this one still not:
$ gawk '/\\\x24Id: .*\\\x24/ {print}' <<< '$Id: rcsid$'
(5)
At long last, this matches again:
$ gawk '/\x5c\x24Id: .*\x5c\x24/ {print}' <<< '$Id: rcsid$'
$Id: rcsid$
which looks to me awkward and quite counterintuitive.
-------------
The problem with (1) is that when the regexp is in a file under RCS
control, RCS will destroy the regexp upon checkout by performing a
keyword substitution. So the straightforward and seemingly manual-
compliant solution would be (2), which is unfortunately not.
I wonder if I found a gawk bug or a flaw in the regexp / literal / meta
concept or a vague place in the gawk manual. Or just misunderstood
something?
-------------
OS:
$ uname -a
Linux gygv 5.2.18-200.fc30.x86_64 #1 SMP Tue Oct 1 13:14:07 UTC 2019
x86_64 x86_64 x86_64 GNU/Linux
gawk:
$ gawk --version
GNU Awk 4.2.1, API: 2.0 (GNU MPFR 3.1.6-p2, GNU MP 6.1.2)
Copyright (C) 1989, 1991-2018 Free Software Foundation.
gawk manual:
This is Edition 4.2 of GAWK: Effective AWK Programming
yours
KP
- [bug-gawk] Is \x24 the literal dollar character?,
Kozics Peter (FM) <=