Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to turn off (stupid) warnings in GAWK (4.1.4)

510 views
Skip to first unread message

Kenny McCormack

unread,
Aug 5, 2017, 9:35:24 AM8/5/17
to
For some reason, under certain circumstances, one of my scripts generates
this bogus error message:

gawk: ./zzz.awk:17: (FILENAME=- FNR=23) warning: Invalid multibyte data
detected. There may be a mismatch between your data and your locale.

Which messes up my output display. I can squelch this by the usual shell
hack (2>/dev/null), but I was wondering if there was a built-in way to turn
it off.

Note that TAWK has a "-w" command line option to turn off warnings, as well
as a WARNINGS built-in variable for more fine-grained control. Does GAWK
have anything similar?

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/Mandela

Joe User

unread,
Aug 5, 2017, 10:45:55 AM8/5/17
to
Kenny McCormack wrote:

> For some reason, under certain circumstances, one of my scripts generates
> this bogus error message:
>
> gawk: ./zzz.awk:17: (FILENAME=- FNR=23) warning: Invalid multibyte data
> detected. There may be a mismatch between your data and your locale.
>
> Which messes up my output display. I can squelch this by the usual shell
> hack (2>/dev/null), but I was wondering if there was a built-in way to
> turn it off.
>
> Note that TAWK has a "-w" command line option to turn off warnings, as
> well
> as a WARNINGS built-in variable for more fine-grained control. Does GAWK
> have anything similar?
>

Given that particular warning, you are probably reading an ASCII file under
some other encoding. Just a guess.

The best way to squelch that particular warning is with the -b, or --
characters-as-bytes option. That reads input files byte-by-byte, with ASCII
encoding.

Otherwise, you can redirect stderr to stdout, and filter the process output
to remove that particular warning. Or, with bash, redirect like 2>(filter).



Kenny McCormack

unread,
Aug 5, 2017, 11:29:12 AM8/5/17
to
In article <415e9$5985d80f$adf2c163$44...@API-DIGITAL.COM>,
Joe User <ax...@yahoo.com> wrote:
...
>Given that particular warning, you are probably reading an ASCII file under
>some other encoding. Just a guess.

OK - whatever that means. But thanks for posting.

>The best way to squelch that particular warning is with the -b, or --
>characters-as-bytes option. That reads input files byte-by-byte, with ASCII
>encoding.

Yes! Adding -b to the options list fixed the problem (made the error
message go away). It also, incidentally, fixed another migration issue in
the script output, so it is an unqualified good.

Every once in a while, the Usenet actually performs as intended. A
question is posted; a sensible, useful answer is given; everybody leaves
happy. Well done!

P.S. That all said, I'm still curious if there's a general way in GAWK
(i.e., not via the shell or filters or whatever) to squelch warnings.

--
"The party of Lincoln has become the party of John Wilkes Booth."

- Carlos Alazraqui -

Joe User

unread,
Aug 5, 2017, 5:16:16 PM8/5/17
to
Kenny McCormack wrote:

> Every once in a while, the Usenet actually performs as intended. A
> question is posted; a sensible, useful answer is given; everybody leaves
> happy. Well done!

Usenet is also intended for porn and insult contests.


Eric Pement

unread,
Aug 6, 2017, 10:05:15 PM8/6/17
to
On Saturday, August 5, 2017, the question was asked:

> Note that TAWK has a "-w" command line option to turn off warnings, as well
> as a WARNINGS built-in variable for more fine-grained control. Does GAWK
> have anything similar?

> P.S. That all said, I'm still curious if there's a general way in GAWK
> (i.e., not via the shell or filters or whatever) to squelch warnings.

Try setting the variable LC_ALL=C in the shell (such as in the .bash_profile or .bashrc startup file). That may help. I also think setting the GNU awk variable BINMODE=3 inside a BEGIN{...} block may resolve this issue.

HTH.

Kenny McCormack

unread,
Jan 27, 2018, 6:32:35 AM1/27/18
to
In article <1255f181-1ae1-49ac...@googlegroups.com>,
Still missing the point.

I've tried to make it clear that I'm no longer talking about the specific
instance given. I'm talking about a general method to squelch warnings -
regardless of which topic they pertain to.

Like TAWK's "-w" option.

--
If you think you have any objections to anything I've said above, please
navigate to this URL:
http://www.xmission.com/~gazelle/Truth
This should clear up any misconceptions you may have.

Mike Sanders

unread,
Jan 28, 2018, 7:12:02 AM1/28/18
to
Kenny McCormack <gaz...@shell.xmission.com> wrote:

> I've tried to make it clear...

'You walk into a room and sit down at a table.
Someone brings you a turkey sandwich, a bag of
potato chips, and a soda. Perhaps you are a
vegetarian, or gluten-free. Doesn't matter;
you get a turkey sandwich, a bag of potato
chips, and a soda.'

Hang in there K.

--
later on,
Mike

https://busybox.hypermart.net

Kenny McCormack

unread,
Jan 28, 2018, 7:52:14 AM1/28/18
to
In article <p4kemg$25a$1...@news.albasani.net>,
Mike Sanders <mi...@porkchop.bsd> wrote:
>Kenny McCormack <gaz...@shell.xmission.com> wrote:
>
>> I've tried to make it clear...
>
>'You walk into a room and sit down at a table.
>Someone brings you a turkey sandwich, a bag of
>potato chips, and a soda. Perhaps you are a
>vegetarian, or gluten-free. Doesn't matter;
>you get a turkey sandwich, a bag of potato
>chips, and a soda.'
>
>Hang in there K.

On Usenet, as in life, you get what you get.

--
"There's no chance that the iPhone is going to get any significant market share. No chance." - Steve Ballmer
0 new messages