Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: $? being clobbered?

On Jul 14,  1:35pm, Phil!Gregory wrote:
} Subject: $? being clobbered?
} I'm having a problem with zsh, and am not sure if it's a bug or a
} feature.  If I have a program executed in my prompt, its return status
} clobbers the value of $?, which isn't really what I want.

There's code in the precmd handler to preserve and restore $? but nothing
similar is done during prompt expansion.

Is there some reason to execute the command every time the prompt is
printed?  That is, does the command change from one prompt to the next?
If not, I suggest:

    unsetopt promptsubst
    PROMPT="%{$(echoti cub 80)%}> "	# Note double quotes

Otherwise I suggest using precmd:

    unsetopt promptsubst
    PROMPT='> '
    function precmd {
      echoti cub 80

I feel compelled to remark that moving 80 columns left seems an odd way of
achieving 'setopt promptcr'.

Messages sorted by: Reverse Date, Date, Thread, Author