Why IGNORECASE awk variable does not work properly when its value is set in the command line option?

Jdamian :

I realized that awk -v IGNORECASE=0 is ignoring the case when it shouldn't.

ps -ef | awk -v IGNORECASE=0 '/INIT/'
root          1      0  0  2019 ?        00:03:07 /sbin/init
root      65327  25751  0 08:26 pts/0    00:00:00 awk -v IGNORECASE=0 /INIT/

but awk 'BEGIN { IGNORECASE=0 }' is not ignoring the case as expected.

ps -ef | awk  'BEGIN { IGNORECASE=0 } /INIT/'
root      66290  25751  0 08:27 pts/0    00:00:00 awk BEGIN { IGNORECASE=0 } /INIT/

Why? What am I missing? Is it a bug?

P.D: GNU Awk 3.1.7

jas :

Found in the gawk changelog:

2015-02-05 Andrew J. Schorr

  • eval.c (set_IGNORECASE): If IGNORECASE has a numeric value, try using that before treating it as a string. This fixes a problem where setting -v IGNORECASE=0 on the command line was not working properly.

Bug confirmed. You're not missing anything.

Hopefully you can upgrade to the latest version.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=6595&siteId=1