runawk

Software Screenshot:
runawk
Software Details:
Version: 1.5.0
Upload Date: 19 Feb 15
Developer: Aleksey Cheusov
Distribution Type: Freeware
Downloads: 20

Rating: nan/5 (Total Votes: 0)

runawk is a tiny wrapper for AWK interpreter that impements module system and helps to write the standalone AWK programs.

MOTIVATION

After years of using AWK for programming I've found that despite of
its simplicity and limitations AWK is good enough for scripting a wide
range of different tasks. AWK is not as poweful as their bigger
counterparts like Perl, Ruby, TCL and others but it has their own
advantages like compactness, simplicity and availability on almost all
UNIX-like systems. I personally also like its data-driven nature and
token orientation, very useful technique for simple text processing
utilities.

But! Unfortunately awk interpreters lacks some important features and
sometimes work not as good as it whould be.

Some problems I see (some of them, of course).

1) AWK lacks support for modules. Even if I create small programs, I
often want to use the functions created earlier and already used in
other scripts. That is, it whould great to orginise functions into
so called libraries (modules).

2) In order to pass arguments to #!/usr/bin/awk -f script (not to awk
interpreter), it is necessary to prepand a list of
arguments with -- (two minus signes). In my view, this looks badly.

Example:

awk_program:

    #!/usr/bin/awk -f

    BEGIN {
       for (i=1; i < ARGC; i){
          printf "ARGV [%d]=%s ", i, ARGV [i]
       }
    }


Shell session:

    % awk_program --opt1 --opt2
    /usr/bin/awk: unknown option --opt1 ignored

    /usr/bin/awk: unknown option --opt2 ignored

    % awk_program -- --opt1 --opt2
    ARGV [1]=--opt1
    ARGV [2]=--opt2
    %


In my opinion awk_program script should work like this (just like
normal programs do)

    % awk_program --opt1 --opt2
    ARGV [1]=--opt1
    ARGV [2]=--opt2
    %


It is possible using runawk.

3) When #!/usr/bin/awk -f script handles arguments (options) and wants
to read from stdin, it is necessary to add
/dev/stdin (or `-') as a last argument explicitely.

Example:

awk_program:

    #!/usr/bin/awk -f

    BEGIN {
       if (ARGV [1] == "--flag"){
          flag = 1
          ARGV [1] = "" # to not read file named "--flag"
       }
    }

    {
       print "flag=" flag " $0=" $0
    }


Shell session:

    % echo test | awk_program -- --flag
    % echo test | awk_program -- --flag /dev/stdin
    flag=1 $0=test
    %


Ideally awk_program should work like this

    % echo test | awk_program --flag
    flag=1 $0=test
    %


All these probles are solved by runawk and this is why I wrote it.
I also include a few modules to runawk distribution which are
useful for me and I hope will be helpful for you too.

INSTALLATION

0) BSD make is required. I name it just 'make' but its real name may
   vary.  bmake and pmake are possible names.

   If you need to change the default building options,
   run make like this

     env [YOUR_ASSIGNMENTS] make < target >

   See example section below

1) Uncompress tarball you've downloaded like this

   gzip -dc runawk-X-Y-Z.tar.gz | tar -xf-

2) cd runawk-X-Y-Z

3) make

4) (optional!) make install-dirs

5) make install

There are a lot of Makefile variables that can be changed during
installation.  Runawk's own variables (All they are at the begining of
Makefile):

 PREFIX         - where runawk is installed to
 MODULESDIR     - directory where modules are installed to
 AWK_PROG       - path to awk interpreter
 STDIN_FILENAME - path to stdin device file

BSD make's variables (most commonly used,
for all others - see make's documentation and .mk files)

 BINDIR - where runawk executable itself is installed to
 MANDIR - where manual pages are installed to

 BINOWN - runawk executable owner
 BINGRP - runawk executable group

 MANOWN - man page owner
 MANGRP - man page group

Example:

   env CC=gcc
       PREFIX=/home/cheusov/local
       LDFLAGS='-L/usr/pkg/lib -Wl,-rpath -Wl,/usr/pkg/lib'
       LDADD=-lextralib
       CFLAGS='-Werror -Wall'
       CPPFLAGS=-I/usr/pkg/include
       BINOWN=cheusov
       BINGRP=users
       MANOWN=cheusov
       MANGRP=users
       MKCATPAGES=no
          make -s all install-dirs install

What is new in this release:

  • The options -i, -I, and all long options were completely removed.
  • The option -T was added for tabbed input.
  • The option -v is documented in the man page.
  • Fixes for gcc compilation warnings.
  • Fixes for compilation with non-empty MAKEOBJDIR.
  • Typo fixes in NEW, runcmd.awk, and man pages.

What is new in version 1.4.4:

  • A bug in removing subdirectories in a temporary directory was fixed.
  • Improvements for runawk_modules.3.

What is new in version 1.4.3:

  • paexec(1) doesn't use system(3) anymore for removing the temporary directory.
  • The function print_help() was moved from the power_getopt.awk module to init_getopt.awk.

What is new in version 1.4.2:

  • This version adds runawk_modules.3 where all modules are documented, deprecates long options, removes the -i and -I options, and includes man pages in the distribution tarball so pod2man is not needed for building.

What is new in version 1.4.0:

  • In exitnow.awk, the exitnow(status) function now finishes the execution of the script without running END sections even if status == 0.
  • The new module io.awk includes the functions is_{file,dir,exec,socket,fifo,blockdev,chardev,symlink}, file_size, and file_type. tokenre.awk has the new function splitre0().

What is new in version 1.3.2:

  • Internal arrays are now relocated automatically. This fixes use of runawk(1) in combination with xargs(1), e.g., cat files.txt | xargs runawk -e '...'.

What is new in version 1.3.0:

  • A fix for an Intel C compiler warning message.
  • A fix for the function shquote() from modules/shquote.awk.
  • The source code of the project has been reorganized, thus allowing an easy installation of any subproject: examples, modules, runawk, alt_getopt, and doc (TODO, README, etc. files).

What is new in version 1.1.0:

  • A -F option was added.
  • New ord.awwas ftrans_in.awk, and glob.awk modules were included.
  • A new alt_getopt executable was included for parsing short and long options in shell scripts.
  • New min3, min4, min5, min_key, min_value, and key_of_min_value (min.awk), and max3, max4, max5, max_key, max_value, and key_of_max_value (max.awk) functions were provided.
  • New samples were added: examples/demo_minmax, examples/demo_tokenre3, examples/demo_ftrans, examples/demo_glob*.
  • A new feature was added in multisub.awk.
  • Minor improvements were made in the installation procedure.

What is new in version 0.16.0:

  • Lots of demo programs for most runawk modules were created and they are in examples/ subdirectory now. New MEGA module ;-) power_getopt.awk See the documentation and demo program examples/demo_power_getopt. It makes options handling REALLY easy. New modules: embed_str.awk has_suffix.awk has_prefix.awk readfile.awk modinfo.awk Minor fixes and improvements in dirname.awk and basename.awk. Now they are fully compatible with dirname(1) and basename(1) RUNAWK sets the following environment variables for the child awk subprocess: RUNAWK_MODC - A number of modules (-f filename) passed to AWK RUNAWK_MODV_ - Full path to the module #n, where n is in [0..RUNAWK_MODC) range. RUNAWK sets RUNAWK_ART_STDIN environment variable for the child awk subprocess to 1 if additional/artificial `-' was added to the list to awk's arguments. Makefile: bmake-ism were removed. Now Makefile is fully compatible with FreeBSD make. CLEANFILES target is used instead of hand-made rules Minor fix in 'test_all' target

Similar Software

Other Software of Developer Aleksey Cheusov

paexec
paexec

20 Feb 15

mk-configure
mk-configure

20 Feb 15

LMDBG
LMDBG

20 Feb 15

Comments to runawk

Comments not found
Add Comment
Turn on images!