[Toybox] awk seen in the wild
Andy Chu
andychup at gmail.com
Fri Jul 8 18:26:45 PDT 2016
On Fri, Jul 8, 2016 at 6:01 PM, Ed Maste <emaste at freebsd.org> wrote:
> On 8 July 2016 at 16:36, enh <enh at google.com> wrote:
>> https://github.com/android-ndk/ndk/issues/133#issuecomment-231318129
>> is the first time in about a decade i've seen awk more complicated
>> than "print $2" in the wild...
>>
>> readelf -sW toolkit/library/libxul.so |grep FUNC |awk '$2 ~ /[048c]$/ {print}'
>>
>> ruins my genius plan to "implement" an awk that only supports "print
>> $(\d+)"... :-)
>
> Heh. If you want some contemporary "more complicated" samples there
> are 85 awk scripts in the FreeBSD tree that should serve that purpose.
> https://svnweb.freebsd.org/base/head/tools/tools/nanobsd/mtree-dedup.awk?view=markup
OK sure, this apparently processes a log file and gives you some kind
of file system tree (202 lines)
> https://svnweb.freebsd.org/base/head/sys/tools/makeobjops.awk?view=markup
C code generation (505 lines). OK sure, I've noticed that most shell
implementations use some awk for code generation. There are lots of
enums and string arrays, and awk is great for eliminating redundancy.
> https://svnweb.freebsd.org/base/head/sys/dev/bhnd/tools/nvram_map_gen.awk?view=markup
OK wow, a full parser for a recursive language, and C code generator.
Not unheard of, since Kernighan's book demos recursive descent parsing
in Awk. Has a qsort() implementation and other "library" functions.
1162 lines.
> https://svnweb.freebsd.org/base/head/sys/tools/sound/feeder_rate_mkfilter.awk?view=markup
WOW. OK that's a creative use of awk. It's still a C code generator,
but it's doing lots of floating point math to create audio filters.
899 lines.
Where exactly is this used? Is it just a random user space tool or
actually fundamental to BSD in some way?
Andy
More information about the Toybox
mailing list