diff --git a/powerline/bindings/bash/powerline.sh b/powerline/bindings/bash/powerline.sh index 4ec0d72c..618cb0d0 100644 --- a/powerline/bindings/bash/powerline.sh +++ b/powerline/bindings/bash/powerline.sh @@ -31,10 +31,26 @@ _powerline_return() { return $1 } +_POWERLINE_HAS_PIPESTATUS= + +_powerline_has_pipestatus() { + if test -z "$_POWERLINE_HAS_PIPESTATUS" ; then + _powerline_return 0 | _powerline_return 43 + if test "${PIPESTATUS[*]}" = "0 43" ; then + _POWERLINE_HAS_PIPESTATUS=0 + else + _POWERLINE_HAS_PIPESTATUS=1 + fi + fi + return $_POWERLINE_HAS_PIPESTATUS +} + _powerline_status_wrapper() { local last_exit_code=$? last_pipe_status=( "${PIPESTATUS[@]}" ) - if test "$last_exit_code" != "${last_pipe_status[-1]}" ; then + if ! _powerline_has_pipestatus \ + || test "${#last_pipe_status[@]}" -eq "0" \ + || test "$last_exit_code" != "${last_pipe_status[-1]}" ; then last_pipe_status=() fi "$@" $last_exit_code "${last_pipe_status[*]}"