[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] Using lastpipe causes function that takes stdin to fail
From: |
Jesse Hathaway |
Subject: |
[Help-bash] Using lastpipe causes function that takes stdin to fail |
Date: |
Mon, 12 Nov 2018 09:20:01 -0600 |
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
- [Help-bash] Using lastpipe causes function that takes stdin to fail,
Jesse Hathaway <=