From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29285 invoked from network); 13 Aug 2004 17:35:24 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 13 Aug 2004 17:35:24 -0000 Received: (qmail 95160 invoked from network); 13 Aug 2004 17:35:18 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 13 Aug 2004 17:35:18 -0000 Received: (qmail 28220 invoked by alias); 13 Aug 2004 17:34:33 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7838 Received: (qmail 28210 invoked from network); 13 Aug 2004 17:34:33 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by 130.225.247.90 with SMTP; 13 Aug 2004 17:34:33 -0000 Received: (qmail 93120 invoked from network); 13 Aug 2004 17:32:34 -0000 Received: from unknown (HELO moonbase.zanshin.com) (167.160.213.139) by a.mx.sunsite.dk with SMTP; 13 Aug 2004 17:32:33 -0000 Received: from toltec.zanshin.com (toltec.zanshin.com [64.84.47.166]) by moonbase.zanshin.com (8.12.11/8.12.11) with ESMTP id i7DHWWkM027339 for ; Fri, 13 Aug 2004 10:32:32 -0700 Date: Fri, 13 Aug 2004 10:32:32 -0700 (PDT) From: Bart Schaefer Reply-To: zsh-users@sunsite.dk To: zsh-users@sunsite.dk Subject: Re: Execute a Command in PS1 w/o Disturbing Previous Return Value? In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-0.9 required=6.0 tests=BAYES_30 autolearn=no version=2.63 X-Spam-Hits: -0.9 On Thu, 12 Aug 2004, Aaron Davies wrote: > I'm trying to write a prompt that will do two things: include a file > frequently re-downloaded from the web, and indicate the return status of > the previous command. The problem is, if I cat out the file, it returns > 0, overwriting the return status read by the %(0?%) directive This should probably be considered a bug. > What can I do about this? In addition to Philippe's suggestion of using precmd so that $? is saved and restored for you by the shell -- which is what should be happening during command substitutions in prompt expansion, but isn't -- a simple alternative is to use $(<...) instead of `cat ...`. You can also use $'...' instead of `echo '...'` export PS1='$(