This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Possible issue with gawk 5.0.1-1: Getting new warnings

On Thu, 11 Jul 2019 11:51:09, Vipul P wrote:
Here is a sample script to invoke awk:

$ cat ./
echo "This:is:a:colon:separated:line:%%%:" | awk '{
  gsub("\\%", "%25", $0);
  gsub("\\:", "%3A", $0);

As others said, your invocation is not idiomatic AWK. Anywhere that regular
expressions are expected, like the first argument to "gsub", regular expressions
should be used. If you use a string, you need an extra level of escaping, as
the AWK lexer will parse the string twice:

If the right-hand operand is any expression other than the lexical token
**ERE**, the string value of the expression shall be interpreted as an
extended regular expression, including the escape conventions described
above. Note that these same escape conventions shall also be applied in
determining the value of a string literal (the lexical token **STRING**),
and thus shall be applied a second time when a string literal is used in
this context.

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]