diff --git a/editors/awk.c b/editors/awk.c index e765d3fcfb0d8ad2376a80eb98336268ee12571b..6c60a0615ce5a0a2f1ab1cd2adb5fcda2785602d 100644 --- a/editors/awk.c +++ b/editors/awk.c @@ -3156,7 +3156,8 @@ static var *evaluate(node *op, var *res) if (op1) { rsm = newfile(L.s); if (!rsm->F) { - if (opinfo == TI_PGETLINE) { + /* NB: can't use "opinfo == TI_PGETLINE", would break "cmd" | getline */ + if ((opinfo & OPCLSMASK) == OC_PGETLINE) { rsm->F = popen(L.s, "r"); rsm->is_pipe = TRUE; } else { diff --git a/testsuite/awk.tests b/testsuite/awk.tests index 6b23b91cb59e33c286839990033e88f1d1e2fa1d..242c897d174e144f5380da01855f0f233764fed4 100755 --- a/testsuite/awk.tests +++ b/testsuite/awk.tests @@ -455,4 +455,9 @@ testing "awk print + redirect" \ "STDERR %s\n" \ '' '' +testing "awk \"cmd\" | getline" \ + "awk 'BEGIN { \"echo HELLO\" | getline; print }'" \ + "HELLO\n" \ + '' '' + exit $FAILCOUNT