I am running Ubuntu 14.04.3, it's uptodate. I don't know why, for a few days I began to take grep: write error: Broken pipe
message on launching gnome-terminal . It seems to be harmless but it bothers me. How can I debug it?
EDIT: I moved aliases and functions each to separate files such as .bash_aliases
and .bash_functions
and added a command to load them from .bashrc
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
if [ -f ~/.bash_functions ]; then
. ~/.bash_functions
fi
If I don't load .bash_functions
problem disappears.
I am trying to find the faulty one by disabling each function one by one.
This one gives me the same error but when I disable it I keep getting the same error, so I may have more faulty functions.
ls -lt $PWD| grep ^d | head -1 | cut -b 51-
grep: development
write error: Broken pipe
I wonder why I begin to take that error.
EDIT2:
I found a similar problem here boken pipe
The root of the problem also seems similar.
I tried the given test command in the link which have the same error:
bash -c '(while echo foo; do :; done); echo status=$? >&2' | head
foo
foo
foo
foo
foo
foo
foo
foo
foo
foo
bash: line 0: echo: write error: Broken pipe
status=0
EDIT3:
Though that unbuffer
workaround I posted below as an answer to my own question works, I am not satisfied with it, but my knowledge about debugging is limited. Acoording to this link https://lists.gnu.org/archive/html/bug-coreutils/2007-11/msg00080.html it stems from SIGPIPE trap by another task, and this link https://lists.gnu.org/archive/html/bug-coreutils/2007-11/msg00154.html pinpoints the exact cause of the problem, it's one of the pam authentication module which I am in trouble with it recently.
grep
in your.bashrc
,.profile
, etc. And is it only in gnome-terminal? Not in xterm, or in the TTYs?.bashrc
and.profile
I haven't added any new functions recently. I have a number of grep and | (pipe) in functions in them but they are there for months.shopt -s nullglob; ls -t */ | head -1
I getdevelopment/: ls: write error: Broken pipe
outputls -dt */
indevelopment
directory. Added it to my question.printf '%q' */
in whichever directory you were originally in, and that I meant the replacement function would be:shopt -s nullglob; ls -dt */ | head -1
. Sorry for the miscommunication.