|
Packit |
575503 |
function basename(x) {
|
|
Packit |
575503 |
return gensub(/^.*\//, "", 1, x)
|
|
Packit |
575503 |
}
|
|
Packit |
575503 |
|
|
Packit |
575503 |
BEGIN {
|
|
Packit |
575503 |
print "BEGIN"
|
|
Packit |
575503 |
|
|
Packit |
575503 |
cmd = "echo hello; echo goodbye"
|
|
Packit |
575503 |
rc = get_file(cmd, "<<", -1, res)
|
|
Packit |
575503 |
print "expected error result", rc, ERRNO
|
|
Packit |
575503 |
print "get_file returned", get_file(cmd, "|<", -1, res)
|
|
Packit |
575503 |
print "input_name", basename(res["input_name"])
|
|
Packit |
575503 |
print (cmd | getline x)
|
|
Packit |
575503 |
print x
|
|
Packit |
575503 |
|
|
Packit |
575503 |
# check that calling get_file on "" triggers the BEGINFILE rule
|
|
Packit |
575503 |
print "get_file returned", get_file("", "", -1, res)
|
|
Packit |
575503 |
print "input_name", basename(res["input_name"])
|
|
Packit |
575503 |
print "end BEGIN"
|
|
Packit |
575503 |
}
|
|
Packit |
575503 |
|
|
Packit |
575503 |
BEGINFILE {
|
|
Packit |
575503 |
printf "BEGINFILE (%s) ERRNO (%s)\n", basename(FILENAME), ERRNO
|
|
Packit |
575503 |
}
|
|
Packit |
575503 |
|
|
Packit |
575503 |
ENDFILE {
|
|
Packit |
575503 |
printf "ENDFILE (%s) ERRNO (%s)\n", basename(FILENAME), ERRNO
|
|
Packit |
575503 |
}
|
|
Packit |
575503 |
|
|
Packit |
575503 |
END {
|
|
Packit |
575503 |
print "END"
|
|
Packit |
575503 |
print (cmd | getline x)
|
|
Packit |
575503 |
print x
|
|
Packit |
575503 |
print close(cmd)
|
|
Packit |
575503 |
}
|