Bash – Why did BASH print “bash: cd: write error: Success”

bash

I noticed this several times today. If I type cd ../Directory to change to another directory, it prints "bash: cd: write error: Success". I can't determine what other previous commands might be related to this.

  • typeset -f prints nothing.
  • alias prints nothing.
  • type -a cd prints "cd is a shell builtin".
  • echo $CDPATH prints an empty line.
  • $BASH_VERSION prints "bash: 4.2.37(1)-release: command not found".
  • I only noticed this 2-3 times. The initial directory and target directory were identical in both situations. I changed directories in this manner many other times, but did not encounter the error always.

What could be causing this?

Best Answer

Maybe a bug?

This sounds like a potential bug. I found a similar report showing the same message. The bug bash: pwd builtin exits with write error: Success.

excerpt

This message will be displayed if ferror(stdout) returns non-zero. For some reason (probably the fflush() call immediately preceding the check), stdio is causing ferror() to return true without setting errno.

Does this happen twice in a row? The pwd builtin calls clearerr() after printing the error message, so even if the stdout error flag `sticks', that should clear it.

Can't update history?

The error makes me think that it was successful in changing directories, but wasn't able to write the command cd ../Directory to your $HOME/.bash_history. I'd confirm that this file is intact and is writable. Also confirm that your $HOME directory is writable and not full.

$ df -h $HOME
Filesystem                         Size  Used Avail Use% Mounted on
/dev/mapper/fedora_greeneggs-home  402G  157G  225G  42% /home
Related Question