diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2015-03-27 06:40:45 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2015-03-27 06:40:45 +0300 |
commit | 3fad6ad12e1637c4e1b72fbeaf0265f44da0cf27 (patch) | |
tree | 8e83597d27430370914142150647e11c07410e0b /test/getfile.awk | |
parent | 603eb56251817ac19491b7671ed01402b2d7399c (diff) | |
parent | 7d3d7d27391db40c0561ea47e6b8a5a1ae24c6fb (diff) | |
download | egawk-3fad6ad12e1637c4e1b72fbeaf0265f44da0cf27.tar.gz egawk-3fad6ad12e1637c4e1b72fbeaf0265f44da0cf27.tar.bz2 egawk-3fad6ad12e1637c4e1b72fbeaf0265f44da0cf27.zip |
Merge branch 'master' into wasted-byte
Diffstat (limited to 'test/getfile.awk')
-rw-r--r-- | test/getfile.awk | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/getfile.awk b/test/getfile.awk new file mode 100644 index 00000000..6ee783f6 --- /dev/null +++ b/test/getfile.awk @@ -0,0 +1,35 @@ +function basename(x) { + return gensub(/^.*\//, "", 1, x) +} + +BEGIN { + print "BEGIN" + + cmd = "echo hello; echo goodbye" + rc = get_file(cmd, "<<", -1, res) + print "expected error result", rc, ERRNO + print "get_file returned", get_file(cmd, "|<", -1, res) + print "input_name", basename(res["input_name"]) + print (cmd | getline x) + print x + + # check that calling get_file on "" triggers the BEGINFILE rule + print "get_file returned", get_file("", "", -1, res) + print "input_name", basename(res["input_name"]) + print "end BEGIN" +} + +BEGINFILE { + printf "BEGINFILE (%s) ERRNO (%s)\n", basename(FILENAME), ERRNO +} + +ENDFILE { + printf "ENDFILE (%s) ERRNO (%s)\n", basename(FILENAME), ERRNO +} + +END { + print "END" + print (cmd | getline x) + print x + print close(cmd) +} |