From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2373 invoked by alias); 20 Aug 2010 12:36:48 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28177 Received: (qmail 16120 invoked from network); 20 Aug 2010 12:36:46 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at vinc17.net does not designate permitted sender hosts) Date: Fri, 20 Aug 2010 14:28:23 +0200 From: Vincent Lefevre To: zsh-workers@zsh.org Subject: prompt problem Message-ID: <20100820122823.GA4702@ypig.lip.ens-lyon.fr> Mail-Followup-To: zsh-workers@zsh.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Mailer-Info: http://www.vinc17.org/mutt/ User-Agent: Mutt/1.5.20-6127-vl-r38670 (2010-08-14) After a "zsh -f", source the following: precmd() { psvar[1]=$? if [[ $psvar[1] -gt 128 ]] then local sig=$signals[$(($psvar[1]-127))] [[ -n $sig ]] && psvar[1]=$sig fi } TRAPCLD() { [[ -o interactive && -n $TTY ]] && precmd } PS1="%m:%20<...<%~%<<%(?..[%1v])%(#.#.>) " then execute { sleep 3 } | { sleep 3 } | { sleep 3 } | { sleep 3 } and interrupt it with Ctrl-C. I can see two unexpected behaviors (not always reproducible, one needs to try several times), as seen here: ypig:~[INT]> { sleep 3 } | { sleep 3 } | { sleep 3 } | { sleep 3 } ^C% ypig:~[INT]> { sleep 3 } | { sleep 3 } | { sleep 3 } | { sleep 3 } ^C% ypig:~[INT]> { sleep 3 } | { sleep 3 } | { sleep 3 } | { sleep 3 } ^C% ypig:~[INT]> { sleep 3 } | { sleep 3 } | { sleep 3 } | { sleep 3 } ^C% ypig:~[INT]> ypig:~[INT]> { sleep 3 } | { sleep 3 } | { sleep 3 } | { sleep 3 } ^C% ypig:~[INT]> { sleep 3 } | { sleep 3 } | { sleep 3 } | { sleep 3 } ^C% ypig:~[0]> { sleep 3 } | { sleep 3 } | { sleep 3 } | { sleep 3 } ^C% ypig:~[0]> { sleep 3 } | { sleep 3 } | { sleep 3 } | { sleep 3 } ^C% So, sometimes the prompt is output twice. This seems to be a bug. I sometimes get a "[0]" instead of "[INT]". This one may be due to the fact that $? is 0 in the trap. I wonder whether this is correct. At least the behavior doesn't seem to be consistent with: ypig:~> sleep 5 & [1] 9217 ypig:~> blah zsh: command not found: blah ypig:~[127]> ypig:~[127]> [1] + done sleep 5 ypig:~[127]> ypig:~[127]> echo $? 127 where the value of $? seems to be preserved after "sleep 5" has terminated. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)