Incidentally, if you set PS1 as ... PS1='[$( X=${PWD#$HOME}; [ "$X" = "$PWD" ] || X="~$X"; printf %s "$X")]; '
then you get the same effect as the version you used, but without running any external programs, and with just one fork (for the command substitution itself), instead of 3 or something.. It probably makes little difference (performance of interactive prompting isn't usually critical), and the pwd|sed version is probably easier to understand, but just in case... kre ps: It turns out this also works around the bug that was there, though I have not looked closely to see why, but unless you care to use it until you get a fixed sh, that's mostly irrelevant.