From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7229 invoked from network); 25 Dec 2007 19:14:47 -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.6 required=5.0 tests=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; 25 Dec 2007 19:14:47 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 49682 invoked from network); 25 Dec 2007 19:14:38 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 25 Dec 2007 19:14:38 -0000 Received: (qmail 13776 invoked by alias); 25 Dec 2007 19:14:34 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 24320 Received: (qmail 9473 invoked from network); 25 Dec 2007 19:07:53 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 25 Dec 2007 19:07:53 -0000 Received: from virusfilter.dotsrc.org (bifrost [127.0.0.1]) by spamfilter.dotsrc.org (Postfix) with ESMTP id 767A58058F9A for ; Tue, 25 Dec 2007 20:04:09 +0100 (CET) Received: from mail1.sea5.speakeasy.net (mail1.sea5.speakeasy.net [69.17.117.3]) by bifrost.dotsrc.org (Postfix) with ESMTP for ; Tue, 25 Dec 2007 20:04:08 +0100 (CET) Received: (qmail 10886 invoked from network); 25 Dec 2007 19:07:47 -0000 Received: from cldmz-nat-12-108-127-191.pittsburgh.intel-research.net (HELO [10.212.129.152]) (kaminsky@[12.108.127.191]) (envelope-sender ) by mail1.sea5.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 25 Dec 2007 19:07:47 -0000 Message-ID: <477154ED.70001@csail.mit.edu> Date: Tue, 25 Dec 2007 14:07:25 -0500 From: Michael Kaminsky User-Agent: Mozilla-Thunderbird 2.0.0.6 (X11/20071009) MIME-Version: 1.0 To: zsh-workers@sunsite.dk Subject: zero elapsed time in history with certain preexec functions Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP I sent this message to zsh-users in August, but didn't see any response. In case it fell through the cracks, I'm re-sending to zsh-workers. Can anyone say if this is a bug? Is there a fix or work-around? Note: I re-tested everything below with "zsh -f" and the behavior is the same. After "zsh -f" you need to "setopt" the options list in the first example: extendedhistory histignoredups histignorespace histnostore. Please CC me on any responses as I'm not on the list. Thanks, Michael ------------------------------------------------- I use zsh's preexec function to set the title of my terminal, similar to many of the examples posted online. After defining preexec, however, I noticed that zsh wasn't recording the duration of commands anymore. After much experimentation, I believe I've come up some simple examples to illustrate this behavior: $ zsh --version zsh 4.3.4 (i686-pc-linux-gnu) $ setopt|grep hist extendedhistory histignoredups histignorespace histnostore $ unfunction preexec $ sleep 2 $ fc -ldD |tail -1 12004 11:16 0:02 sleep 2 (so far, so good) $ function preexec { echo $ZSH_VERSION } $ sleep 2 4.3.4 $ fc -ldD |tail -1 4.3.4 12014 11:18 0:02 sleep 2 (still good, but...) $ function preexec { echo $ZSH_VERSION[1] } 4.3.4 $ sleep 2 4 $ fc -ldD |tail -1 4 12016 11:20 0:00 sleep 2 It appears that subscripting a variable (or indexing into a zsh array) inside of the preexec function causes zsh not to record the elapsed time/duration of the command. There may be other actions that trigger this behavior. Another quick example: $ function preexec() { echo $1 } $ sleep 2 sleep 2 $ fc -ldD |tail -1 fc -ldD |tail -1 12040 11:25 0:02 sleep 2 (but...) $ function preexec() { echo ${(z)1} } function preexec() { echo ${(z)1} } $ sleep 2 sleep 2 $ fc -ldD |tail -1 fc -ldD | tail -1 12044 11:27 0:00 sleep 2 Any ideas? Michael