Can't parse command substitution containing here-document and pipeline
Bug #1855606 reported by
Sam Kendall
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
mksh |
Invalid
|
Undecided
|
Unassigned |
Bug Description
This scriptlet, boiled down from production code, fails with "syntax error: '|' unexpected":
a=$(cat <<EOF | cat
hello
EOF
)
[ "$a" = hello ]
The following variation fails in the same way:
a=$(cat <<EOF |
hello
EOF
cat
)
[ "$a" = hello ]
Those scriptlets work in ksh93, ksh88 (AIX and Solaris), bash, and even pdksh 5.2.14 (RHEL 4). I've reproduced the failures in mksh R56 (RHEL 8) and R46 (RHEL 7).
It's the combination of $( ), here-document, and pipeline that provokes the bug. Take away one of those elements, and there's no trouble.
To post a comment you must log in.
Duplicate of https:/ /bugs.launchpad .net/mksh/ +bug/1783355