From: Vinícius d. S. O. <vin...@gm...> - 2021-06-24 15:20:10
|
Would it be possible to add an API to gawk that allows the plugin author to check whether there's a certain rule in the AWK script? The use-case is that I want to offer something similar to BEGINFILE. If the user doesn't write a rule to handle some specific use case, the program will abort when/if it happens. If the user does write a rule for it then the program doesn't abort and just executes the user's rule. I just need to check a very simple expression, "read var X". For instance (the first rule): JSONRECORDERROR { next } .. { ... } .. { ... } .. { ... } No other types of AWK expressions need to be checked against. I don't need to know if the user wrote the rule "JSONRECORDERROR && somethingelse". I only need to know if he wrote the rule "JSONRECORDERROR" exactly (no other variation). There's no need to "merge multiple rules" in the likes of BEGINFILE either. Just consume the AWK program as it normally would and nothing else. All I want is to check on plugin startup if the user wrote a certain rule of a very simple pattern. The abort behaviour is something I write on my own plugin and shouldn't be part of this API addition. How does that sound? Too fancy? Too weirdo? Too far-fetched? Or is it reasonable after all? -- Vinícius dos Santos Oliveira https://vinipsmaker.github.io/ |