commit: https://git.busybox.net/busybox/commit/?id=39aabfe8f033c9c62acf676b660dc979714d26a7
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
function old new delta
evaluate 3337 3343 +6
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
editors/awk.c | 3 ++-
testsuite/awk.tests | 5 +++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/editors/awk.c b/editors/awk.c
index e765d3fcf..6c60a0615 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 6b23b91cb..242c897d1 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