====================================================================== Version 1.6.1, by Aleksey Cheusov, Fri, 15 Feb 2019 21:19:26 +0300 Fix in regression test (broken Solaris shell) Sort .awk files locale-independently to get reproducible build ====================================================================== Version 1.6.0, by Aleksey Cheusov, Fri, 26 Dec 2014 12:34:12 +0300 Environment variable RUNAWK_KEEPTMP was introduced. If it set, temporary files are kept. This is useful for debugging. io.awk:file_size was fixed (its behaviour depended on FS value) AWK_PROGS used for testing is now settable from environment. A few typos in runawk_modules.3 were fixed. Thanks to Andrew Shadura! ====================================================================== Version 1.5.1, by Aleksey Cheusov, Sat, 28 Jun 2014 18:00:25 +0300 Compilation failure on Hurd was fixed. mk-configure >= 0.26.0 is required for build. ====================================================================== Version 1.5.0, by Aleksey Cheusov, Sun, 8 Sep 2013 12:10:47 +0300 Options -i, -I and all long options were completely removed. Option -T was added. For details see the man page. Option -v is documented in manpage. Fixes for gcc compilation warnings. Fixes for compilation with non-empty MAKEOBJDIR. Typo fixes in NEW, runcmd.awk and man pages. ====================================================================== Version 1.4.4, by Aleksey Cheusov, Sat, 10 Nov 2012 13:57:35 +0300 Fix for bug in removing subdirs in temporary directory. Improvements and bug fix in runawk_modules.3 ====================================================================== Version 1.4.3, by Aleksey Cheusov, Sun, 9 Sep 2012 21:54:21 +0300 runawk: - Clean-ups in usage message - system(3) is not used anymore for removing temporary directory modules: - Function print_help() has been moved from power_getopt.awk to init_getopt.awk ====================================================================== Version 1.4.2, by Aleksey Cheusov, Sun, 19 Aug 2012 23:00:39 +0300 runawk_modules.3 was added where all modules are documented Long options are considered deprecated -i and -I options were removed man pages are included to a distribution tarball, so pod2man is not needed for building ====================================================================== Version 1.4.1, by Aleksey Cheusov, Sun, 22 Jul 2012 14:57:19 +0300 Minor fixes in documentation Path to AWK interpreter is detected at build time (not hardcoded /usr/bin/awk). This fixes runawk on, for example, Haiku. Clean-ups in build system. mk-configure-0.23.0 is required. ====================================================================== Version 1.4.0, by Aleksey Cheusov, Sun, 27 Nov 2011 21:41:09 +0300 exitnow.awk: - Fix: exitnow(status) finishes the execution of the script without running END sections even if status == 0. New module io.awk that includes the following functions: is_{file,dir,exec,socket,fifo,blockdev,chardev,symlink}, file_size and file_type. tokenre.awk: - Function splitre0() was added that splits $0 More regression tests were added. ====================================================================== Version 1.3.2, by Aleksey Cheusov, Sun, 9 Oct 2011 14:11:32 +0300 Internal arrays are relocated automatically. This fixes use of runawk(1) in combination with xargs(1), e.g. cat files.txt | xargs runawk -e '...' ====================================================================== Version 1.3.1, by Aleksey Cheusov, Fri, 7 Jan 2011 16:45:30 +0200 runawk.1 and alt_getopt.1 are included to tarball, so pod2man is not needed for installation. No functional changes in source code. ====================================================================== Version 1.3.0, by Aleksey Cheusov, Tue, 4 Jan 2011 20:14:04 +0200 fix in runawk.c for warning message produced by Intel C compiler. fix for shquote("") from modules/shquote.awk. Source code is reorganized and it is easy to install examples, modules, alt_getopt, runawk executable and TODO/README/... files individually. See doc/INSTALL for details. mk-configure >= 0.21 is required ====================================================================== Version 1.2.0, by Aleksey Cheusov, Sat, 23 Oct 2010 00:35:35 +0300 Due to incompatibilities between traditional BSD mk files and mk files shipped with bmake by Simon J. Gerraty, I've decided to switch runawk from BSD mk files to mk-configure software build system. This makes Makefile significantly smaller, easier to understand and use and gives tons of new capabilities. Obviously this makes development even easier than before. Updated installation instruction is in README. New functions in heapsort.awk: "heapsort_fields" and "heapsort0" for sorting $1, $2 ... New function in tokenre.awk: "splitre". New samples of use (regression tests): examples/demo_tokenre4, demo_heapsort4. ====================================================================== Version 1.1.0, by Aleksey Cheusov, Wed, 6 Oct 2010 22:51:56 +0300 Makefile: - initialize {BIN,MAN}{OWN,GRP} to `id -{u,g}n`. You don't need to set these variables manually for unprivileged installation. Option -F is added to runawk. It passes field separator to AWK interpreter. New tool alt_getopt(1), an alternative to getopt(1) and POSIX shell's getopts. alt_getopt is a command options parser that undestands long options. It is implemented in runawk and uses its modules. Also alt_getopt.sh shell include file is implemented and installed. Examples: examples/demo_alt_getopt*.sh multisub.awk: ability to skip a matched text is added, see the documentation at the top of multisub.awk and examples/demo_multisub for the sample. Function multisub now has optional third argument. New module glob.awk for working with glob patterns. See examples/demo_glob* for the samples. min.awk: new functions min3, min4, min5, min_key, min_value and key_of_min_value max.awk: new functions max3, max4, max5, max_key, max_value and key_of_max_value New module ord.awk from GNU awk. New module ftrans_in.awk from GNU awk (fixed and modified by me). Example: examples/demo_ftrans. New example: examples/demo_tokenre3. Thanks to Vlad Shakhov for the idea. New example: examples/demo_minmax. ====================================================================== Version 1.0.0, by Aleksey Cheusov, Sun, 5 Sep 2010 16:39:47 +0300 New functions for sorting indices in hash heapsort.awk: heapsort_indices quicksort.awk: quicksort_indices sort.awk: sort_indices New module ini.awk for reading .ini files. ====================================================================== Version 0.21.0, by Aleksey Cheusov, Sun, 28 Mar 2010 13:43:48 +0300 fixed: compilation failure on recent Linux-es (warn_unused_result attribute of system(3) function in recent glibc). fixed: compilation failures on FreeBSD ("assignment discards qualifiers from pointer target type" warning which is critical with -Werror). fixed: compilation failure with Intel C Compiler Now one can pass arguments to awk program specified with -e option after --, that is like the following runawk -e '' -- New simple modules: - trim.awk: this modules provides a set of simple functions for trimming spaces from the string. - backslash_in.awk treats backslash symbol at the end of input line as "this line will continue on the next line". $ cat ~/tmp/9.txt Some text here \ and here too. \ This is still the first line. This is the second. And this is third one that\ continues on the next line \ and the next line too. Ok, we finally have four lines of text. $ runawk -f backslash_in.awk -e '{print}' ~/tmp/9.txt Some text here and here too. This is still the first line. This is the second. And this is third one that continues on the next line and the next line too. Ok, we finally have four lines of text. $ - trim_in.awk trims spaces from input lines. - CR_in.awk removes CR symbols from input lines. ====================================================================== Version 0.20.0, by Aleksey Cheusov, Thu, 4 Mar 2010 18:33:03 +0200 New module: fieldwidths.awk: By default AWK interpreter splits input lines into tokens according to regular expression that defines "spaces" between them using special variable FS. Sometimes it is useful to define a fixed-size fields for tokens. This is what this module is for. The functionality of fieldwidths.awk is very close to GNU awk's FIELDWIDTHS variable but is available for all flavours of AWK ;-) New module: tmpfile.awk: This module provides a function `tmpfile' for generating temporary filenames. All these filenames are under temporary directory created (if necessary) by runawk(1) which is removed automatically during normal exit or when runawk(1) reveives SIGINT, SIGQUIT, SIGTERM, SIGHUP or SIGPIPE. Thus, this module provides a safe way to work with temporary files. new runawk directive: #interp-var that specifies an environment variable name that keeps a preferred AWK interpreter. See a manual page for details. new runawk directive: #safe-use that #use module if it exists. Example is below. For more details see a manual page. foobar application: #!/usr/bin/env runawk #safe-use "~/.foobarrc" "/etc/foobar.conf" BEGIN { print foo, bar, baz } config file ~/.foobarrc for foobar application: BEGIN { foo = "foo10" bar = "bar20" baz = 123 } fix in power_getopt.awk: arguments equal to "" (empty string) are now processed correctly. power_getopt.awk: after options processing ARGV [1], ARGV [2], ..., ARGV [ARGC-1] are set to non-option arguments. new in heapsort.awk: functions sift_down and sift_up. fix in tokenre.awk: There is no need to initialize TRE variable, it is already initialized to "" at startup. This fixes a problem with 'runawk -v TRE=lalala ...' Minor fixes and rewords in the runawk.1 and README. ====================================================================== Version 0.19.0, by Aleksey Cheusov, Sun, 3 Jan 2010 15:23:31 +0200 fix in runawk.c: \n was missed in "running '%s' failed: %s" error message. The problem was seen on ancient (12 years old) HP-UX fix in teets/test.mk: "diff -u" is not portable (SunOS, HP-UX), DIFF_PROG variable is introduced to fix the problem fix in modules/power_getopt.awk: after printing help message we should exit immediately not running END section, s/exit/exitnow/ new function heapsort_values in heapsort.awk module new function quicksort_values in quicksort.awk module new function sort_values in sort.awk module ====================================================================== Version 0.18.0, by Aleksey Cheusov, Sat, 7 Nov 2009 17:08:16 +0200 Makefile: !!! "install-dirs" target has been renamed to "installdirs" !!! - At compile time MODULESDIR can contain a *list* of colon-separated directories, e.g. /usr/local/share/runawk:/usr/local/share/awk - power_getopt.awk, alt_getopt.awk and init_getopt.awk: - Support for multiply applied options, e.g. -vvv for increasing verbosity level. If option without arguments is multiply applied, getarg() function returns a number of times it was applied, not just 0 or 1. New modules: - init_getopt.awk using alt_getopt.awk and used by power_getopt.awk. Its goal is to initialize `long_opts' and `long_opts' variables but not run `getopt' function. - heapsort.awk - heapsort :-) - quicksort.awk - quicksort :-) - sort.awk - either heapsort or quicksort, the default is heapsort. Unfortunately GAWK's asort() and asorti() functions do *not* satisfy my needs. Another (and more important) reason is a portability. Improvements, clean-ups and fixes in regression tests. runawk-0-18-0 was successfully tested on the following platforms: NetBSD-5.0/x86, NetBSD-2.0/alpha, OpenBSD-4.5/x86, FreeBSD-7.1/x86, FreeBSD-7.1/spark, Linux/x86 and Darwin/ppc. ====================================================================== Version 0.17.0, by Aleksey Cheusov, Sat, 12 Sep 2009 01:29:31 +0300 runawk: - ADDED: new option for runawk for #use'ing modules: -f. runawk can also be used for oneliners! ;-) runawk -f abs.awk -e 'BEGIN {print abs(-123); exit}' - In a multilined code passed to runawk using option -e, spaces are allowed before #directives. - After inventing alt_getopt.awk module there is no reason for heuristics that detects whether to add `-' to AWK arguments or not. So I've removed this heuristics. Use alt_getopt.awk module or other "smart" module for handling options correctly! alt_getopt.awk and power_getopt.awk: - FIX: for "abc:" short options specifier BSD and GNU getopt(3) accept "-acb" and understand it as "-a -cb", they also accept "-ac b" and also translate it to "-a -cb". Now alt_getopt.awk and power_getopt.awk work the same way. power_getopt.awk: - -h option doesn't print usage information, --help (and its short synonym) does. New modules: - shquote.awk, implementing shquote() function. shquote(str): `shquote' transforms the string `str' by adding shell escape and quoting characters to include it to the system() and popen() functions as an argument, so that the arguments will have the correct values after being evaluated by the shell. Inspired by NetBSD's shquote(3) from libc. - runcmd.awk, implementing functions runcmd1() and xruncmd1() runcmd1(CMD, OPTS, FILE): wrapper for function system() that runs a command CMD with options OPTS and one filename FILE. Unlike system(CMD " " OPTS " " FILE) the function runcmd1() handles correctly FILE and CMD containing spaces, single quote, double quote, tilde etc. xruncmd1(FILE): safe wrapper for 'runcmd(1)'. awk exits with error if running command failed. - isnum.awk, implementing trivial isnum() function, see the source code. - alt_join.awk, implementing the following functions: join_keys(HASH, SEP): returns string consisting of all keys from HASH separated by SEP. join_values(HASH, SEP): returns string consisting of all values from HASH separated by SEP. join_by_numkeys (ARRAY, SEP [, START [, END]]): returns string consisting of all values from ARRAY separated by SEP. Indices from START (default: 1) to END (default: +inf) are analysed. Collecting values is stopped on index absent in ARRAY. ====================================================================== Version 0.16.0, by Aleksey Cheusov, Sun, 5 Apr 2009 12:45:44 +0300 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 ====================================================================== Version 0.15.0, by Aleksey Cheusov, Fri, 19 Dec 2008 21:41:00 +0200 new module alt_getopt.awk that implements 'getopt' function compatible with "Utility Syntax Guidelines" described in "Single UNIX Specification" http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html#tag_12_02 "getopt" function from this module is similar to C function getopt(3) (Idiotic GNU getopt(3) must die!) Better heuristics for adding `-' to the list awk's arguments, now it better conforms to "Utility Syntax Guidelines". Makefile: STDIN_FILENAME defaults to `-', not `/dev/stdin' Interix has no /dev/stdin file Makefile: WARNS=4 ====> WARNS?= 4 Makefile: CPPFLAGS -> CFLAGS, FreeBSD make mk scripts don't support CPPFLAGS Lots of regression tests for 'getopt' function ====================================================================== Version 0.14.3, by Aleksey Cheusov, Sat, 18 Oct 2008 19:39:47 +0300 The following code no longer fails with NAWK under NetBSD runawk -e ' { print "123" } ' /dev/null fixed: compilation bug under FreeBSD (WARNS=4 -> warning -> error) caused by comparison of signed and unsigned values More verbose output when stat(filename) failed modules/str2regexp.awk: adapted to buggy MAWK ====================================================================== Version 0.14.2, by Aleksey Cheusov, Fri, 29 Aug 2008 17:28:34 +0300 Temporary file is removed if runawk is killed by SIGINT, SIGQUIT, SIGTERM, SIGHUP or SIGPIPE signals. (Temporary file is created by 'runawk -e ...') ====================================================================== Version 0.14.1, by Aleksey Cheusov, Sat, 19 Jul 2008 22:53:45 +0300 FIXED: The following code doesn't work with runawk-0.14.0 runawk -e ' #use "anymodule.awk" ' This code requires a creation of the temporary file that was removed in runawk-0.14.0. Now temporary file is created using mkstemp(3). Regression tests are created for testing. ====================================================================== Version 0.14.0, by Aleksey Cheusov, Sat, 12 Jul 2008 17:29:22 +0300 Temporary file is not needed anymore for -e option. FIXED: #env didn't work under Linux/glibc. FIXED: compilation error under FreeBSD. Lots of new regression tests. Code clean-ups. fgetln is not required anymore. No hacks about it. If error happens while processing a #directive, a correct line number is output ====================================================================== Version 0.13.0, by Aleksey Cheusov, Sun, 15 Jun 2008 11:30:06 +0300 ADDED: option -v|--assign that works like AWK's -v option. This is to pass some variables to AWK interpreter. Example: runawk -v var=123 -e 'BEGIN {print var }' modules/xgetline.awk: better error message/clean-ups modules/abort.awk: NR is also printed to stderr minor fixes in *.c clean-ups and fixes in 'make test'. Now it doesn't depend on my own system and runawk directory 'make test' exits with non-zero exit status if regression tests fail Makefile: ported to ancient pmake-1.45 found in some Linux distros ====================================================================== Version 0.12.a, by Aleksey Cheusov, Mon, Tue, 4 Mar fix in alt_assert.awk ====================================================================== Version 0.12.0, by Aleksey Cheusov, Mon, 3 Mar 2008 23:04:10 +0200 new directive '#env' is implemented. It sets environment for running awk subprocess using setenv(3) Example: #!/usr/local/bin/runawk #env "LC_ALL=C" $1 ~ /^[A-Z]+$/ { # A-Z is valid if LC_CTYPE=C print $1 } New modules match_br.awk match_br(STRING, BR_OPEN, BR_CLOSE) return start position (or zero if failure) of the substring surrounded by balanced (), [], {} or similar characters Also sets RSTART and RLENGTH variables just like the standard 'match' function does For example: print match_br("A (B (), C(D,C,F (), 123))", "(", ")") print RSTART, RLENGTH -| 3 -| 3 -| 24 braceexpand.awk braceexp(STRING) implement shell-like brace expansion For example: print braceexpand("ab{,22{,7,8}}z{8,9}") -| abz8 abz9 ab22z8 ab22z9 ab227z8 ab227z9 ab228z8 ab228z9 exitnow.awk see the code. exitnow.awk is used by alt_assert.awk and abort.awk abort.awk abort(MSG, EXIT_STATUS) -- print MSG to stderr and exits program with EXIT_STATUS. if EXIT_STATUS is zero of is not specified, 1 is assigned. dirname.awk similar to UNIX's dirname(1) basename.awk similar to UNIX's basename(1) xgetline.awk xgetline0([FILE]) Safe analog to 'getline < FILE' or 'getline' (if no FILE is specified). 0 at the end means that input line is assigned to $0. xgetline([FILE]) Safe analog to 'getline __input < FILE' and 'getline __input' (if no FILE is specified) In both cases "safe" means that returned value is analysed and if it is less than zero (file reading error happens) program will be terminated emmidiately with appropriate error message printed to stderr. Both functions return zero if end of file is reached or non-zero if reading was sucessfull. Example: while (xgetline("/etc/passwd")){ print "user: " __input } xclose.awk xsystem.awk -- safe wrappers over 'close' and 'system' functions ====================================================================== Version 0.11.0, by Aleksey Cheusov, Sat, 9 Feb 2008 17:35:59 +0200 New modules tokenre.awk: By default AWK splits input strings into tokens according to regular expression that defines "space" between tokens using special variable FS. In many situations it is more useful to define regular expressions for tokens themselves. This is what this module does. tokenre(STRING, REGEXP) `tokenre' extracts substrings from STRING according to REGEXP from the left to the right and assigns $1, $2 etc. and NF variable. tokenre0(REGEXP) Does the the same as `tokenre' but splits $0 instead TRE - variable. If it is set to not empty string, splitting is made by default for all input strings. For example: tokenre("print \"Hello world!\"", "\"([^\"]|\\\")*\"|[[:alnum:]_]+") | NF == 2 | $1 == print | $2 == "Hello world!" str2regexp.awk str2regex(STRING) returns a regular expression that matches given STRING For example: print str2regexp("all special symbols: ^$(){}[].*+?|\\") -| all special symbols: [^][$][(][)][{][}][[]\][.][*][+][?][|]\\ multisub.awk multisub(STRING, SUBST_REPLS) `multisub' is a substitution function. It searches for a list of substrings, specified in SUBST_REPL in a left-most longest order and (if found) replaces found fragments with appropriate replacement. SUBST_REPL format: "SUBSTRING1:REPLACEMENT1 SUBSTRING2:REPLACEMENT2...". Three spaces separate substring:replacement pairs from each other. For example: print multisub("ABBABBBBBBAAB", "ABB:c BBA:d AB:e") |- ccBBde new target 'test_all' runs tests for all available awk interpreters ====================================================================== Version 0.10.1, by Aleksey Cheusov, Fri, 1 Feb 2008 21:25:48 +0200 FIXED: If AWK interpreter segfaults or killed by any other signal, runawk exits with exit status 0. Affected runawk versions: all. Now this is fixed and runawk exits with exit status 128+SIGNAL just like many shells. EXIT STATUS section has been added to the manual page. ====================================================================== Version 0.10.0, by Aleksey Cheusov, Wed, 23 Jan 2008 00:38:31 +0200 ADDED: The environment variable RUNAWK_AWKPROG overrides the default awk interpreter which is set at compile time. Documentation updated accordingly. FIXED: unsafe use of strdup(3) I've copied MIT License text to code from www.opensource.org. Do you see any difference? ADDED: new trivial module pow.awk that implements function "pow" fix: MKMAN and MKCATPAGES make's standard variables are checked during installation In order to build runawk not in a directory you can either build it like this (standard way) cd /src/dir; make all install MAKEOBJDIR=/obj/dir or like this cd /obj/dir; make -f /src/dir/Makefile all install optional config.h is #included if you need it other minor fixes and improvements both in code and documentation ====================================================================== Version 0.9.0, by Aleksey Cheusov, Sun, 23 Dec 2007 22:20:23 +0200 I switched to BSD make. I really hate automake and its approach in general. I'm not expert in BSD, but their 'make' looks much better. But using it makes some changes in building process, see README/INSTALLATION section for a brief description. ADDED: man page for runawk. HTML version runawk.html can also be generated from runawk.pod using pod2html, see Makefile. ADDED: -i/-I options for forcing/disabling adding /dev/stdin to the list of awk arguments. See man page for more information. A few AWK modules are installed to PREFIX/share/runawk: abs.awk, min.awk, max.awk and alt_assert.awk. This directory is also checked while searching for modules. See man page for more details. AWK_PROG and STDIN_FILENAME Makefile variables can be passed to make program to change a path to an actual AWK interpreter (/usr/bin/awk by default) and stdin file (/dev/stdin by default). Lots of improvements in documentation ADDED: regression tests. Run them by running 'make test' and let me know if somethiung fails. debugging output is sent stdout, not stderr ADDED: long synonyms for short options, --help, --version etc. clean-ups in Makefile options handling improvements ====================================================================== Version 0.8.1, by Aleksey Cheusov, Wed, 24 Oct 2007 14:46:12 +0300 FIXED: default stdin file should be /std/stdin, not /dev/stderr, I've made a typo. ====================================================================== Version 0.8.0, by Aleksey Cheusov, Sun, 21 Oct 2007 17:19:46 +0300 FIXED: return code of execvp is not analysed, i.e. when running an interpreter fails, runawk silently exits with zero exit status. Now it fails with exit status 1 and print an error to stderr. stdin filename defaults to "/dev/stdin" ROOT variable in Makefile has been renamed to more commonly used PREFIX realloc(2) is not used anymore. arrays[ARRAY_SZ] are used now. AWK and STDIN_FILENAME variables are removed from Makefile. Use CPPFLAGS for changing defaults. ====================================================================== Version 0.7.0, by Aleksey Cheusov, Sat, 22 Sep 2007 02:30:26 +0300 First publicly available release. See README for a documentation ======================================================================