Execute arbitrary commands in redirect inclusion

The current implementation of `<|` does not handle arbitrary commands,
like e.g. the `$PLAN9/src/mkhdr` file:

    <| cat $PLAN9/config 2>/dev/null || true

Signed-off-by: Florian Limberger <flo@purplekraken.com>
This commit is contained in:
Florian Limberger 2020-04-23 12:54:23 +02:00
parent 73d1b31466
commit 90057b78e4

View file

@ -113,9 +113,10 @@ func parsePipeInclude(p *parser, t token) parserStateFun {
p.basicErrorAtToken("empty pipe include", t) p.basicErrorAtToken("empty pipe include", t)
} }
args := make([]string, len(p.tokenbuf)) args := make([]string, len(p.tokenbuf) + 1)
args[0] = "-c"
for i := 0; i < len(p.tokenbuf); i++ { for i := 0; i < len(p.tokenbuf); i++ {
args[i] = p.tokenbuf[i].val args[i + 1] = p.tokenbuf[i].val
} }
output, success := subprocess("sh", args, "", true) output, success := subprocess("sh", args, "", true)