From: Michael Kaminsky <kaminsky@csail.mit.edu>
To: zsh-workers@sunsite.dk
Subject: zero elapsed time in history with certain preexec functions
Date: Tue, 25 Dec 2007 14:07:25 -0500 [thread overview]
Message-ID: <477154ED.70001@csail.mit.edu> (raw)
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
next reply other threads:[~2007-12-25 19:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-25 19:07 Michael Kaminsky [this message]
2007-12-29 18:33 ` Bart Schaefer
2008-01-03 17:23 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=477154ED.70001@csail.mit.edu \
--to=kaminsky@csail.mit.edu \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).