bash_kernel
bash_kernel copied to clipboard
Broken Pipe Errors
Using any type of non-trivial pipe prints a "Broken pipe" error.
For example, use the following code snippet:
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
Executing in bash behaves as expected:
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
3JT1JUE_NE8-CcgaJXfkESNfWLgiVIWd
Executing in ipython (notebook or console both give same error):
In [1]: < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
QgmPQRyp0u1Lllf6c4Y5mAE8FxM563A_tr: write error: Broken pipe
tr: write error
same errors here:

I do get the results I need but the errors are somewhat annoying :)
I can reproduce it, but I have no idea what's going on with this.
looks like this should help: https://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline
although that will probably be a pain to manage nested commands such as echo $(ls | grep something) | grep something
The bash_kernel is not emulating bash in Python: it's actually running a bash shell in a separate process and sending your code to that.
So i'm getting the same error as well, https://blog.nelhage.com/2010/02/a-very-subtle-bug/ is this what's causing it?
Aha, good find. I think that might well be it. Would you like to make a PR? pexpect's spawn() now takes a preexec_fn like subprocess.
I'm getting odd broken pipe errors too. Is this issue still open or could it be something new?
I'm also getting this issue with zcat