Re: How to programmatically detect awk flavor (e.g. gawk vs mawk vs nawk vs awk)

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

 



On 10/18/2015 11:31 AM, Itamar Gal wrote:
> Hey autoconf gang,
> 
> I recently posted a question to unix.stackexchange.com asking for the best
> way to programmatically determine which flavor of awk is present on a given
> host.

In the autoconf philosophy, does it really matter?  Either write your
awk script to be common to the lowest denominator of the awk
implementations, or pick a feature that you want to use from a given awk
implementation and probe that the particular feature is supported
(regardless of which flavor of awk is running the probe script).  If you
do only feature probes, rather than version/implementation probes, then
it won't hurt if some implementation later gains the feature you were
probing for.

> 
> Someone suggested using the AC_PROG_AWK macro, but didn't elaborate on how
> this would work. Unforunately I'm only passingly familiar with the GNU
> build system and I can't quite make sense of the autoconf source code that
> I've looked at (e.g. programs.m4 and autoconf.m4f).
> 
> Can anyone here explain to a novice like me how I might be able to make use
> of this macro to construct a simple bash script which determines which
> variety of awk is in the path?


The expansion of that macro demonstrates how to probe whether a given
awk meets certain minimum capabilities, via feature probes.  To use
additional features, you would extend the number of feature probes being
done in that sort of feature probing loop.

For seeing what the actual macros do, it may be easier to read the
expanded results in a configure file, than it is to read the
pre-expanded m4 code in programs.m4, to get a better feel for the shell
code emitted for probing for awk.

Probably not the best answer, but I'm also not the best awk expert
around here.  Good luck

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux