Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PS1='%?'
- X-seq: zsh-users 11896
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Atom Smasher <atom@xxxxxxxxxxx>
- Subject: Re: PS1='%?'
- Date: Sat, 29 Sep 2007 13:02:10 +0100
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <20070929112153.76128.qmail@xxxxxxxxxxx>
- Mail-followup-to: Atom Smasher <atom@xxxxxxxxxxx>, zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20070929112153.76128.qmail@xxxxxxxxxxx>
On Sat, Sep 29, 2007 at 11:21:48PM +1200, Atom Smasher wrote:
> if i have a '%?' in my command line, is there a way to "reset" it to zero
> if i hit enter, but don't run a command?
[...]
If the shell were to behave like that, that would mean that in
cmd
if [ "$?" -ge 2 ]; ...
The test above would be useless because of the empty line above
that would have reset $? to 0.
What you could do is redefine the accept-line widget (called
upon <Return> key press) so that it runs the null command (":")
if the edit buffer is empty:
~$ accept-line() {
function> [[ -n $BUFFER ]] || BUFFER=:
function> zle .accept-line
function> }
~$ zle -N accept-line
~$ false
(1)~$ :
~$ :
But why do you want to reset $? in such a way?
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author