(2023-05-08) Making POSIX AWK great again: introducing The Great Library
------------------------------------------------------------------------
As I had already said, AWK is a heavily underrated tool available for pretty
much every normal OS out there. And even in its standard-compliant version, 
it is capable of doing a lot of useful things. However, I have some plans 
for some rather ambitious projects, but these projects would include several 
things POSIX AWK doesn't offer out of the box, and most of them are not even 
offered by GAWK:

* single-character keyboard input (both blocking and non-blocking),
* ASCII and UTF-8 codepoint conversion for further output or processing,
* loading binary files into arrays and saving arrays into binary files,
* some math functions available in C standard library but missing from
standard AWK for some reasons (like sign, floor, ceil, tan, cotan),
* and, of course, cross-platform bitwise operations.

To think of it, implementation of all this stuff would put AWK on par with
Python or at least Lua when it comes to interactive apps and binary data 
processing. But, of course, not everything here can be implemented with AWK 
itself, and sometimes we have to rely on some external commands. If we limit 
these commands and their options to the ones required by POSIX as well 
though, we still should be fine. The most obvious examples are how we can 
implement single-character keyboard input and loading binary files 
(considering all the null bytes they may have): we just use the od command 
that can shape everything as decimals of the byte width we specify. To 
achieve unbuffered character input, we can also use od in conjunction with 
terminal modes set with the the stty command. Since both stty and od are a 
part of POSIX, we can, as long as we only use the options listed there, 
safely use them to extend AWK script capabilities. And this is what I have 
used in my tgl.awk, which, as you may have guessed, stands for The Great 
Library, as I have called it on my main hoi.st page.

So, how do we use it? Although AWK generally doesn't have the "include"
feature (except the most recent GAWK), we can just use several -f flags one 
after another, which is fully supported by the standard. There also is a 
caveat when using this library with GAWK: in order for any string-related 
functions to work correctly, it requires LANG=C environment variable to be 
set. It won't hurt, however, to set this variable for any other AWK version 
either. So, the most correct way of running any TGL-enabled AWK program in a 
POSIX environment is like this:

LANG=C awk -f tgl.awk -f your_prog.awk [...args...]

This library is subject to change/update in the future, although I believe
it's already close to its final state. I'm not going to introduce any more 
feature creep unless it's absolutely necessary to continue with active 
projects. And in regard of what we can do with the already existing 
functionality, I hope you'll find this out very soon.

--- Luxferre ---