The problem is that if you do not issue another command, $? does not change. Therefore, when your invitation is reevaluated, it correctly emits 127 . There really is no workaround for this other than manually entering another command at the prompt.
edit: Actually, I lied, there are always ways to save state, so can you save the value of $? and check if it has changed, and clear the invitation, if any. But since you are in a subshell, your options are quite limited: you will need to use a file or something as dirty to save the value.
source share