Possible issue with gawk 5.0.1-1: Getting new warnings

Steven Penny svnpenn@gmail.com
Fri Jul 12 22:29:00 GMT 2019


On Thu, 11 Jul 2019 11:51:09, Vipul P wrote:
> Here is a sample script to invoke awk:
> 
> $ cat ./gawk_error.sh
> #!/bin/sh
> echo "This:is:a:colon:separated:line:%%%:" | awk '{
>   gsub("\\%", "%25", $0);
>   gsub("\\:", "%3A", $0);
>   print
>   }'

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.

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html#tag_20_06_13_04


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list