help-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Feature request: Exception handling


From: Wolfgang Laun
Subject: Re: Feature request: Exception handling
Date: Fri, 18 Nov 2022 10:03:16 +0100

For the wording, "bomb out" and "crash" are very vague.

* If there is a fatal error in the program, gawk *terminates *and emits a
diagnostic.
* If gawk runs into an internal error (due to a bug), there's should also
be a diagnostic.

If you would post an example of such a "crash" people could analyze it and
offer help or inform the bug list. From what you write, I can only guess
that you use "raw" data as the first argument of gsub(). If this is not a
correct regular expression, a program error is diagnosed and the program
terminates.

Exception handling would not really help you, not any more than some code
determining whether the ominous string contains some "magic" characters.
(Note that the string might contain a formally correct but logically
incorrect regular expression, instructing gsub() to do extremely weird
changes to the target string. Is this what you want?)

Perhaps a simple combination of index(), length(), substr() and
concatenation would achieve what you want here, without the risk of a
program termination?

Regards
Wolfgang







On Fri, 18 Nov 2022 at 01:44, Arthur G <arthurg.work@gmail.com> wrote:

> Hello,
>
> I've used AWK forever and currently use it to process massive FTP logs
> which sometimes contain strings that make gawk crash.
> E.g. When passing a field to gsub() and the field contains the [ open
> square bracket character which gsub interprets as regex rather than a
> literal.
>
> I guess I could pre-filter that record out before invoking gawk but my
> script already takes 8 hours to run. I guess you could even argue that
> gsub() is not the right function for processing raw user data.
>
> It would be cool if gawk had an exception handler that could be configured
> to run a user specified gawk command or gawk function whenever an error
> occurred when processing data allowing me to decide the next course of
> action to take and continue with my processing if desired.
>
> Currently gawk just just bombs out in this situation.
>
> Thank you,
> Arthur.
>


-- 
Wolfgang Laun


reply via email to

[Prev in Thread] Current Thread [Next in Thread]