• busybox AWK (Was: gawk on Windows)

    From gazelle@gazelle@shell.xmission.com (Kenny McCormack) to comp.lang.awk on Tue Jul 26 12:49:41 2022
    From Newsgroup: comp.lang.awk

    In article <20220726094300.910641200F1@fleegle.mixmin.net>,
    Igenlode Wordsmith <Use-Author-Supplied-Address-Header@[127.1]> wrote:
    ...
    Thanks - an interesting suggestion, especially as I wasn't aware of
    having any gawk-specific code.

    However, a quick test using "gawk -c" for compatibility mode immediately >throws up 'strftime' as being a gawk extension, and as the whole script
    is based heavily around checking formatted dates it looks as if I do
    need gawk in particular. Which is worth knowing anyhow...

    Interestingly enough, I just tested busybox AWK on Linux, and it has strftime(). Color me both surprised and impressed. In fact, though I
    expected it to be pretty easy to find something that broke it, I was unable
    to do it (in a very short/quick session of playing with it).

    So, I'd give it a try.

    P.S. I wouldn't be all that surprised if the AWK in busybox *was* (more or less) gawk. Like, where else would they look?

    P.P.S. OK, yeah, I just tested some more and (surprising absolutely no
    one), it does not recognize the "-l" command line option, so you can't load functions from a shared library, like you can in GAWK...
    --
    In Usenet, as in life, as you go through it, you will run into lots of nonsense.
    Each time, you will have to decide from the following courses of action:
    1) Argue with it or 2) Ignore it.
    Experience shows that the later course is usually the best.
    --- Synchronet 3.19c-Linux NewsLink 1.113
  • From Kaz Kylheku@480-992-1380@kylheku.com to comp.lang.awk on Tue Jul 26 20:21:05 2022
    From Newsgroup: comp.lang.awk

    On 2022-07-26, Kenny McCormack <gazelle@shell.xmission.com> wrote:
    In article <20220726094300.910641200F1@fleegle.mixmin.net>,
    Igenlode Wordsmith <Use-Author-Supplied-Address-Header@[127.1]> wrote:
    ...
    Thanks - an interesting suggestion, especially as I wasn't aware of
    having any gawk-specific code.

    However, a quick test using "gawk -c" for compatibility mode immediately >>throws up 'strftime' as being a gawk extension, and as the whole script
    is based heavily around checking formatted dates it looks as if I do
    need gawk in particular. Which is worth knowing anyhow...

    Interestingly enough, I just tested busybox AWK on Linux, and it has strftime(). Color me both surprised and impressed. In fact, though I

    Why; this is a a standard C library function dating back to ANSI C 89
    (and beyond) with a fixed arity. Wrapping it in a programming language interpreter that already wraps other library functions should about a 30
    minute job, including documentation (which would just point the user
    to the manual for strftime for the format codes).

    expected it to be pretty easy to find something that broke it, I was unable to do it (in a very short/quick session of playing with it).

    So, I'd give it a try.

    P.S. I wouldn't be all that surprised if the AWK in busybox *was* (more or less) gawk. Like, where else would they look?

    The Awk in BusyBox is definitely not Gawk; and that sort of inclusion
    would defeat the whole point of BusyBox.

    The point of BusyBox is providing common utilities in a small space,
    mainly for embedded systems. BusyBox compiles all the utilities into
    a single executable.

    Here is BusyBox on one Arm-based embedded system I'm working with:

    # ls -l /bin/busybox.nosuid
    -rwxrwxr-x 1 1000 1000 1052020 Jul 22 23:36 /bin/busybox.nosuid

    It's about a megabyte, which contains all the utilities BusyBox
    provides, including the shell and Awk.

    GNU Awk alone would probably take up something like 80% of that size.

    Not everything in BusyBox is original. For instance, regarding the
    shell, the source tree contains the ports of two shells: ash
    (the Almquist shell) and something called hush. GNU Bash would not
    be practical.

    BusyBox Awk seems original, though. Oh look, by someone with
    an Ukrainian e-mail address:

    /*
    * awk implementation for busybox
    *
    * Copyright (C) 2002 by Dmitry Zakharov <dmit@crp.bank.gov.ua>
    *
    * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    */
    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    --- Synchronet 3.19c-Linux NewsLink 1.113
  • From Igenlode Wordsmith@Use-Author-Supplied-Address-Header@[127.1] to comp.lang.awk on Wed Jul 27 00:13:38 2022
    From Newsgroup: comp.lang.awk

    On 26 Jul 2022 Kaz Kylheku wrote:

    On 2022-07-26, Kenny McCormack <gazelle@shell.xmission.com> wrote:
    In article <20220726094300.910641200F1@fleegle.mixmin.net>,
    Igenlode Wordsmith <Use-Author-Supplied-Address-Header@[127.1]> wrote:
    ...
    Thanks - an interesting suggestion, especially as I wasn't aware of >>>having any gawk-specific code.

    However, a quick test using "gawk -c" for compatibility mode immediately >>>throws up 'strftime' as being a gawk extension, and as the whole script >>>is based heavily around checking formatted dates it looks as if I do
    need gawk in particular. Which is worth knowing anyhow...

    Interestingly enough, I just tested busybox AWK on Linux, and it has
    strftime(). Color me both surprised and impressed. In fact, though I

    Why; this is a a standard C library function dating back to ANSI C 89
    (and beyond) with a fixed arity. Wrapping it in a programming language >interpreter that already wraps other library functions should about a 30 >minute job, including documentation (which would just point the user
    to the manual for strftime for the format codes).

    [snip]

    Well, I ran the --lint option over my script, and it didn't highlight
    anything other than strftime() as a gawk extension... although just from
    a manual scan I can see that I used 'nextfile', and *that* is listed as
    being available in gawk only. So I'm not sure how far the lint results
    are to be relied upon :-(


    Otherwise a small self-contained implementation sounds like exactly what
    I am looking for...



    (I could post the entire script here to see if anyone can spot anything
    else. But it's embarrassingly spaghetti-fied...)



    The Awk in BusyBox is definitely not Gawk; and that sort of inclusion
    would defeat the whole point of BusyBox.

    The point of BusyBox is providing common utilities in a small space,
    mainly for embedded systems. BusyBox compiles all the utilities into
    a single executable.

    I found a mention of Busybox awk in the page on Other Versions, where it
    is described as "a full implementation of POSIX awk": https://www.gnu.org/software/gawk/manual/html_node/Other-Versions.html

    Testing with the --posix option doesn't throw up anything other than
    strftime, which ironically Busybox awk apparently does support.

    [Edit: assuming this is in fact the Busybox awk source code, the list
    of keywords in static const char tokenlist[] includes both 'strftime'
    and 'nextfile' https://github.com/brgl/busybox/blob/master/editors/awk.c
    ]


    Here is BusyBox on one Arm-based embedded system I'm working with:

    # ls -l /bin/busybox.nosuid
    -rwxrwxr-x 1 1000 1000 1052020 Jul 22 23:36 /bin/busybox.nosuid

    It's about a megabyte, which contains all the utilities BusyBox
    provides, including the shell and Awk.

    GNU Awk alone would probably take up something like 80% of that size.

    My copy of gawk is 1326Kb as a stand-alone file - the binaries directory
    in one of the Windows distributions I downloaded last night was 5Mb.
    --
    Igenlode Visit the Ivory Tower http://ivory.ueuo.com/Tower/

    Those jaded in their emotions demand monstrous things to arouse them

    --- Synchronet 3.19c-Linux NewsLink 1.113