This is, unfortunately, by design. I’ve committed a manpage change (in CAVEATS) with a rationale, though.
** Changed in: mksh Status: Triaged => Invalid -- You received this bug notification because you are a member of mksh Mailing List, which is subscribed to mksh. Matching subscriptions: mkshlist-to-mksh-bugmail https://bugs.launchpad.net/bugs/1804504 Title: -o pipefail makes while read loop ugly Status in mksh: Invalid Bug description: tc.sh: set -x set -e cat >tc.in <<\EOF one eins two zwei three drei EOF while IFS=' ' read a b; do # $a = t* and it works [[ $a = o* ]] && echo $b done <tc.in | sort -u >tc.out echo after the loop cat tc.out echo and out This works with t* both with set ±o pipefail, and with t* in ksh93, but t* in mksh with set -o pipefail makes it error out *after* the “while” because the last comparison error’d out. Workarounds include negating the comparison… [[ $a != o* ]] || echo $b … so that the loop always has $?=0, or: while :; do IFS=' ' read a b || break Interestingly enough, removing the “| sort -u” also makes it work. To manage notifications about this bug go to: https://bugs.launchpad.net/mksh/+bug/1804504/+subscriptions