Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Piping and run_tee swallows output to sys.stderr of the rear end of piped commands #677

Open
simlei opened this issue Apr 16, 2024 · 0 comments

Comments

@simlei
Copy link

simlei commented Apr 16, 2024

Take the following constructs:

/tmp/test.py

import plumbum as pb

cmd = (pb.local["/tmp/producer.bash"] | pb.local["/tmp/consumer.bash"])
c,o,e = cmd.run_tee()

/tmp/producer.bash

#!/usr/bin/env bash
echo "PROD: OUT: LINE 1" >/dev/stdout
echo "PROD: OUT: LINE 2" >/dev/stdout
echo "PROD: ERR: LINE 1" >/dev/stderr
echo "PROD: ERR: LINE 2" >/dev/stderr

/tmp/consumer.bash

#!/usr/bin/env bash
while read -r line; do
    echo "STDERR: line read: $line" >/dev/stderr
    echo "STDOUT: line read: $line" >/dev/stdout
done

and execute

python /tmp/test.py
The output is:

STDOUT: line read: PROD: OUT: LINE 1
STDOUT: line read: PROD: OUT: LINE 2
PROD: ERR: LINE 1
PROD: ERR: LINE 2

However, my expectation would be:

PROD: ERR: LINE 1
PROD: ERR: LINE 2
STDERR: line read: PROD: OUT: LINE 1
STDOUT: line read: PROD: OUT: LINE 1
STDERR: line read: PROD: OUT: LINE 2
STDOUT: line read: PROD: OUT: LINE 2

The STDERR: line read... outputs of the rear of the pipe are swallowed somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant