Discussion:
Using lastpipe causes function that takes stdin to fail
(too old to reply)
Jesse Hathaway
2018-11-12 15:20:01 UTC
Permalink
I ran into a strange issue last week when attempting to pipe some
output into a bash function. The function would always return with an
error code of 127. I was able to narrow the cause down my use of the
`lastpipe` option. When I run the below minimal test case without
`lastpipe`, it completes successfully, but when I use `lastpipe`, the
function returns an error code of 127. I ran the failing program
through strace and it appeared the problem might be due to a wait
system call that doesn't find any matching pids? Any help would be
greatly appreciated, i'm stumped.

; cat lastpipe
#!/bin/bash

set -o pipefail

function bubbles() {
cat | cat
date
}

if echo 'butter' | bubbles; then
echo "SUCCESS: $?"
else
echo "FAILED: $?"
fi

; bash lastpipe
butter
Mon Nov 12 09:10:13 CST 2018
SUCCESS: 0

; bash -O lastpipe lastpipe
butter
Mon Nov 12 09:10:20 CST 2018
FAILED: 127
Chet Ramey
2018-11-12 18:16:21 UTC
Permalink
Post by Jesse Hathaway
I ran into a strange issue last week when attempting to pipe some
output into a bash function. The function would always return with an
error code of 127. I was able to narrow the cause down my use of the
`lastpipe` option. When I run the below minimal test case without
`lastpipe`, it completes successfully, but when I use `lastpipe`, the
function returns an error code of 127. I ran the failing program
through strace and it appeared the problem might be due to a wait
system call that doesn't find any matching pids? Any help would be
greatly appreciated, i'm stumped.
Thanks for the report. This was a bug having to do with the nested
pipelines and lastpipe, fixed back in August as the result of

https://savannah.gnu.org/support/index.php?109541

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU ***@case.edu http://tiswww.cwru.edu/~chet/
Jesse Hathaway
2018-11-12 18:35:07 UTC
Permalink
Post by Chet Ramey
Thanks for the report. This was a bug having to do with the nested
pipelines and lastpipe, fixed back in August as the result of
https://savannah.gnu.org/support/index.php?109541
Thanks Chet, apologies for not checking the bug list. Any thoughts on
when 5.0 will be released?
Chet Ramey
2018-11-12 18:46:05 UTC
Permalink
Post by Jesse Hathaway
Post by Chet Ramey
Thanks for the report. This was a bug having to do with the nested
pipelines and lastpipe, fixed back in August as the result of
https://savannah.gnu.org/support/index.php?109541
Thanks Chet, apologies for not checking the bug list. Any thoughts on
when 5.0 will be released?
I'm trying to prepare a beta2 release right now. I hope to get through
that and a release candidate and get bash-5.0/readline-8.0 out by the
end of the year.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU ***@case.edu http://tiswww.cwru.edu/~chet/
Loading...