public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Possible issue with gawk 5.0.1-1: Getting new warnings
@ 2019-07-11 18:51 Vipul P
  2019-07-12 10:48 ` Houder
  2019-07-12 22:29 ` Steven Penny
  0 siblings, 2 replies; 4+ messages in thread
From: Vipul P @ 2019-07-11 18:51 UTC (permalink / raw)
  To: cygwin

Hello,

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
  }'
----

If I invoke it with gawk 5.0.1-1, I see warnings as below:

$ uname -a
CYGWIN_NT-10.0 MyPC 3.0.7(0.338/5/3) 2019-04-30 18:08 x86_64 Cygwin

$ awk -V
GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2)
Copyright (C) 1989, 1991-2019 Free Software Foundation.
...

$ ./gawk_error.sh
awk: cmd. line:2: (FILENAME=- FNR=1) warning: regexp escape sequence `\%'
is not a known regexp operator
awk: cmd. line:3: (FILENAME=- FNR=1) warning: regexp escape sequence `\:'
is not a known regexp operator
This%3Ais%3Aa%3Acolon%3Aseparated%3Aline%3A%25%25%25%3A

-----
This script runs without any warnings with older versions of gawk:

$ awk -V
GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.1, GNU MP 6.1.2)
Copyright (C) 1989, 1991-2018 Free Software Foundation.
...

$ ./gawk_error.sh
This%3Ais%3Aa%3Acolon%3Aseparated%3Aline%3A%25%25%25%3A

----

The script runs without any warnings on Linux and other Unix variants.

Is this a regression in gawk 5.0.1-1 on Cygwin ?

Thanks in advance.

--
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Possible issue with gawk 5.0.1-1: Getting new warnings
  2019-07-11 18:51 Possible issue with gawk 5.0.1-1: Getting new warnings Vipul P
@ 2019-07-12 10:48 ` Houder
  2019-07-12 14:43   ` Brian Inglis
  2019-07-12 22:29 ` Steven Penny
  1 sibling, 1 reply; 4+ messages in thread
From: Houder @ 2019-07-12 10:48 UTC (permalink / raw)
  To: cygwin

Hi,

Apparently Corinna V. (the maintainer of gawk) is not available at the moment.

On Thu, 11 Jul 2019 11:51:09, Vipul P  wrote:
> Hello,
> 
> 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
>   }'

?????

gsub(regexp, replacement[, target])

echo "This:is:a:colon:separated:line:%%%:" | awk '{
  gsub(/%/, "%25");
  gsub(/:/, "%3A");
  print
  }'

> ----
> 
> If I invoke it with gawk 5.0.1-1, I see warnings as below:
> 
> $ uname -a
> CYGWIN_NT-10.0 MyPC 3.0.7(0.338/5/3) 2019-04-30 18:08 x86_64 Cygwin
> 
> $ awk -V
> GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2)
> Copyright (C) 1989, 1991-2019 Free Software Foundation.
> ...
> 
> $ ./gawk_error.sh
> awk: cmd. line:2: (FILENAME=- FNR=1) warning: regexp escape sequence `\%'
> is not a known regexp operator
> awk: cmd. line:3: (FILENAME=- FNR=1) warning: regexp escape sequence `\:'
> is not a known regexp operator
> This%3Ais%3Aa%3Acolon%3Aseparated%3Aline%3A%25%25%25%3A

I am not surprised to see these specific warnings ...

See 3.2 (esacpe sequences) of GAWK: Effective AWK programming.

> -----
> This script runs without any warnings with older versions of gawk:
[snip]

    https://cygwin.com/ml/cygwin/2019-04/msg00095.html
    ( [ANNOUNCEMENT] gawk 5.0.0-1 )

Item 3

> ----
> 
> The script runs without any warnings on Linux and other Unix variants.

Using version 5 of gawk?

> 
> Is this a regression in gawk 5.0.1-1 on Cygwin ?

Not very likely, as Corinna V. uses the tarball provided by Arnold R.

Regards,
Henri


--
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Possible issue with gawk 5.0.1-1: Getting new warnings
  2019-07-12 10:48 ` Houder
@ 2019-07-12 14:43   ` Brian Inglis
  0 siblings, 0 replies; 4+ messages in thread
From: Brian Inglis @ 2019-07-12 14:43 UTC (permalink / raw)
  To: cygwin

On 2019-07-12 04:47, Houder wrote:
> 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
>>   }'
> gsub(regexp, replacement[, target])
> echo "This:is:a:colon:separated:line:%%%:" | awk '{
>   gsub(/%/, "%25");
>   gsub(/:/, "%3A");
>   print
>   }'
>> If I invoke it with gawk 5.0.1-1, I see warnings as below:
>> $ uname -a
>> CYGWIN_NT-10.0 MyPC 3.0.7(0.338/5/3) 2019-04-30 18:08 x86_64 Cygwin
>> $ awk -V
>> GNU Awk 5.0.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2)
>> Copyright (C) 1989, 1991-2019 Free Software Foundation.
>> $ ./gawk_error.sh
>> awk: cmd. line:2: (FILENAME=- FNR=1) warning: regexp escape sequence `\%'
>> is not a known regexp operator
>> awk: cmd. line:3: (FILENAME=- FNR=1) warning: regexp escape sequence `\:'
>> is not a known regexp operator
>> This%3Ais%3Aa%3Acolon%3Aseparated%3Aline%3A%25%25%25%3A
> I am not surprised to see these specific warnings ...
> See 3.2 (escape sequences) of GAWK: Effective AWK programming.
>> This script runs without any warnings with older versions of gawk:
>     https://cygwin.com/ml/cygwin/2019-04/msg00095.html
>     ( [ANNOUNCEMENT] gawk 5.0.0-1 )
>> The script runs without any warnings on Linux and other Unix variants.
> Using version 5 of gawk?
>> Is this a regression in gawk 5.0.1-1 on Cygwin ?
> Not very likely, as Corinna V. uses the tarball provided by Arnold R.

The first gsub argument is a regexp, so using a quoted string it must follow the
rules for a computed regexp: either "%"/":" to match characters alone or
"\\\\%"/"\\\\:" for characters preceded by backslash "\", as you wish.
Specifying only a single backslash regexp /\x/ or double backslash string "\\x",
the character must be a regexp special or it generates a warning message.

$ awk '{gsub("%", "%25", $0);gsub(":", "%3A", $0);print}' \
	<<< "This:is:a:colon:separated:line:%%%:"
This%3Ais%3Aa%3Acolon%3Aseparated%3Aline%3A%25%25%25%3A
$ awk '{gsub("\\\\%", "%25", $0);gsub("\\\\:", "%3A", $0);print}' \
	<<< "This:is:a:colon:separated:line:%%%:"
This:is:a:colon:separated:line:%%%:
$ awk '{gsub(/%/, "%25", $0);gsub(/:/, "%3A", $0);print}' \
	<<< "This:is:a:colon:separated:line:%%%:"
This%3Ais%3Aa%3Acolon%3Aseparated%3Aline%3A%25%25%25%3A
$ awk '{gsub(/\\%/, "%25", $0);gsub(/\\:/, "%3A", $0);print}' \
	<<< "This:is:a:colon:separated:line:%%%:"
This:is:a:colon:separated:line:%%%:

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.

--
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Possible issue with gawk 5.0.1-1: Getting new warnings
  2019-07-11 18:51 Possible issue with gawk 5.0.1-1: Getting new warnings Vipul P
  2019-07-12 10:48 ` Houder
@ 2019-07-12 22:29 ` Steven Penny
  1 sibling, 0 replies; 4+ messages in thread
From: Steven Penny @ 2019-07-12 22:29 UTC (permalink / raw)
  To: cygwin

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-07-12 22:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-11 18:51 Possible issue with gawk 5.0.1-1: Getting new warnings Vipul P
2019-07-12 10:48 ` Houder
2019-07-12 14:43   ` Brian Inglis
2019-07-12 22:29 ` Steven Penny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).