Skip to content

Commit

Permalink
Wire up stdin in system() (#115)
Browse files Browse the repository at this point in the history
First part of fix for #111
  • Loading branch information
benhoyt committed May 17, 2022
1 parent 1c37b3d commit e1d758c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions interp/interp_test.go
Expand Up @@ -562,6 +562,7 @@ BEGIN {
{`BEGIN { print system(">&2 echo error") } # !fuzz`,
"", "error\n0\n", "", ""},
{`BEGIN { print system("exit 42") } # !fuzz`, "", "42\n", "", ""},
{`BEGIN { system("cat") }`, "foo\nbar", "foo\nbar", "", ""},

// Test bytes/unicode handling (GoAWK currently has char==byte, unlike Gawk).
{`BEGIN { print match("food", "foo"), RSTART, RLENGTH } !gawk`, "", "1 1 3\n", "", ""},
Expand Down
1 change: 1 addition & 0 deletions interp/vm.go
Expand Up @@ -1067,6 +1067,7 @@ func (p *interp) callBuiltin(builtinOp compiler.BuiltinOp) error {
}
cmdline := p.toString(p.peekTop())
cmd := p.execShell(cmdline)
cmd.Stdin = p.stdin
cmd.Stdout = p.output
cmd.Stderr = p.errorOutput
_ = p.flushAll() // ensure synchronization
Expand Down

0 comments on commit e1d758c

Please sign in to comment.