From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26108 invoked from network); 29 Sep 2007 15:14:55 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 29 Sep 2007 15:14:55 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 81310 invoked from network); 29 Sep 2007 15:14:48 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 29 Sep 2007 15:14:48 -0000 Received: (qmail 18599 invoked by alias); 29 Sep 2007 15:14:41 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11899 Received: (qmail 18582 invoked from network); 29 Sep 2007 15:14:40 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 29 Sep 2007 15:14:40 -0000 Received: (qmail 80186 invoked from network); 29 Sep 2007 15:14:40 -0000 Received: from atom.smasher.org (69.55.237.145) by a.mx.sunsite.dk with SMTP; 29 Sep 2007 15:14:34 -0000 Received: (qmail 45693 invoked by uid 1000); 29 Sep 2007 15:14:33 -0000 Message-ID: <20070929151433.45692.qmail@smasher.org> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Date: Sun, 30 Sep 2007 03:14:27 +1200 (NZST) From: Atom Smasher In-Reply-To: <20070929120210.GB7515@sc.homeunix.net> MIME-Version: 1.0 OpenPGP: id=0xB88D52E4D9F57808; algo=1 (RSA); size=4096; url=http://atom.smasher.org/pgp.txt References: <20070929112153.76128.qmail@smasher.org> <20070929120210.GB7515@sc.homeunix.net> Subject: Re: PS1='%?' To: zsh-users@sunsite.dk X-POM: The Moon is Waning Gibbous (89% of Full) X-Hashcash: 1:20:0709291514:zsh-users@sunsite.dk::E/FUHpWz6AdjrtOj:0000000000000 0000000000000000000000005hil On Sat, 29 Sep 2007, Stephane Chazelas wrote: > 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 > 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? ==================== if a command returns non-zero, i see the return status in my prompt. sometimes that can be a distraction, and i'd like to "clear" it by hitting . i guess i can add a check for "${options[interactive]}" before resetting the return status so i should be able to avoid the case you've pointed out... but in the test i ran here it seems to not get have a problem with that in a script. ###################### ## clear the return status by pressing accept-line () { if [ '0' != "${?}" ] && [ ! "${BUFFER}" ] then BUFFER=: fi zle .accept-line } zle -N accept-line ###################### this works, but aesthetically i'd prefer if it didn't put a ":" on the command line... any ideas...? -- ...atom ________________________ http://atom.smasher.org/ 762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808 ------------------------------------------------- "I am somehow less interested in the weight and convolutions of Einstein's brain than in the near certainty that people of equal talent have lived and died in cotton fields and sweatshops." -- Stephen Jay Gould