Only first line of a function’s output gets passed through pipe
- Dominant language
- Perl
- Stars
- 3.9k
- Forks
- 213
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
When you pipe the output of a multi-line function (in a shell script), only the first line’s output goes into the pipe, and the rest goes direct to stdout. This is the second issue I had pointed out in #859. The difference between quoted and unquoted versions of the variable I pointed out earlier was a red herring because echoing an unquoted multi-line variable is supposed to replace the newlines with spaces when being displayed.
Reproduction script:
~~~sh
#! /bin/sh
foo() {
printf "baa "
printf "caa "
printf "daa "
}
foo | tr 'a' 'z'
printf "\n"
~~~
Expected output:
~~~
bzz czz dzz
~~~
a-Shell output:
~~~
caa daa bzz
~~~
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.