Op 23-03-17 om 15:44 schreef Dan Douglas: > On 03/23/2017 04:49 AM, Jean Delvare wrote: >> Apparently it requires a more recent version of mksh than we are >> shipping: > > Herestrings are old. Should work in just about any ksh.
They're a ksh93-ism, not a ksh88-ism. pdksh (including OpenBSD ksh) doesn't have them. On those (as on POSIX), you need a here-document to get the same effect: while stuff; do stuff done <<EOF $(cmd) EOF >> $ echo $KSH_VERSION @(#)MIRBSD KSH R50 2014/06/29 openSUSE $ >> ./test_return.sh ./test_return.sh[10]: syntax error: '(' >> unexpected >> >> But indeed works find with the latest upstream version, thanks >> for the pointer. > > It's also not at all equivalent to a pipe. The shell reads the > command output from a pipe, stripping trailing newlines, and dumps > the result into a temporary file, which then adds a trailing > newline, then reads the file back into whatever runs in the loop. In most use cases, that seems like a distinction without a difference. > It will also fail if it expands to more than one word due to lack > of quotes. (That likely caused your error) That is true on bash, but not on mksh. I should probably have added the quotes anyway though, just to avoid that confusion. - M.