bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Not urgent, maybe Non-bug "obscure feature"


From: J Naman
Subject: Not urgent, maybe Non-bug "obscure feature"
Date: Sat, 31 Jul 2021 00:20:00 -0400

I do not feel that this report is a program bug, rather it was not overtly
documented (that I could see) that *strongly typed regexp *are treated
politely when assigned on the Command-Line Option -v. See below. If it
really is a bug, consider not fixing it. I like it!
GAWK Command-Line Option         BEGIN{ # first line is a print statement
...
gawk -v RS="[\\n\\f\\r]"  -f ... typeof(RS)=string ='[\n\f\r]'
gawk -v RS=/[\\n\\f\\r]/  -f ... typeof(RS)=string ='/[\n\f\r]/'
*NOT!* -v RS=@/[\\n\\f\\r]/ -f ... typeof(RS)=regexp ='[*\\*n*\\*f*\\*r]'
gawk -v RS=@/[\n\f\r]/    -f ... typeof(RS)=regexp ='[\n\f\r]'
# *Wonderful! no esc seq req'd*

*gawk Ver 5.1.0* under *Windows *7 x64

Ref: "The variable values given on the command line are processed for
escape sequences (see Section 3.2 [Escape Sequences], page 48). ... The
variable assignment feature is most useful for assigning to variables *such
as RS* ..."
"Unless noted otherwise, all these escape sequences apply to both string
constants *and regexp* constants:"
To summarize: The escape sequences in the preceding list are always
processed first, for both string constants *and regexp* constants. This
happens very early, as soon as awk reads your program." #! -v command
line *before
*awk reads your program ?!?
'Best, John Naman


reply via email to

[Prev in Thread] Current Thread [Next in Thread]