From 6a0d7490ea6ad97aeafb9da04acab13bd3c38e4d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 23 Oct 2010 21:02:15 +0200 Subject: awk: fix segfault on closing non-opened file Signed-off-by: Denys Vlasenko --- testsuite/awk.tests | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'testsuite/awk.tests') diff --git a/testsuite/awk.tests b/testsuite/awk.tests index 56b11ca46..0afe9b9e7 100755 --- a/testsuite/awk.tests +++ b/testsuite/awk.tests @@ -77,6 +77,12 @@ testing "awk string cast (bug 725)" \ testing "awk handles whitespace before array subscript" \ "awk 'BEGIN { arr [3] = 1; print arr [3] }'" "1\n" "" "" +# GNU awk 3.1.5's "print ERRNO" prints "No such file or directory" instead of "2", +# do we need to emulate that as well? +testing "awk handles non-existing file correctly" \ + "awk 'BEGIN { getline line <\"doesnt_exist\"; print ERRNO; ERRNO=0; close(\"doesnt_exist\"); print ERRNO; print \"Ok\" }'" \ + "2\n0\nOk\n" "" "" + prg=' BEGIN { u["a"]=1 -- cgit v1.2.3