Let\'s say I do this in a unix shell
$ some-script.sh | grep mytext $ echo $?
this will give me the exit code of grep
grep
There is a utility named mispipe which is part of the moreutils package.
mispipe
It does exactly that: mispipe some-script.sh 'grep mytext'
mispipe some-script.sh 'grep mytext'