Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: zsh functions not playing nice.

On 19/01/13 09:38 AM, Stephane Chazelas wrote:

Thanks. This is a bit over my head but I get some idea.

~$ type nice
nice is /usr/bin/nice

There's no way it can know about a zsh function which is
something internal to the shell.

It *executes* a command. So what you think is a builtin is
the command version of it in /bin or /usr/bin:
Yes, so I see.
~$ strace -fe execve nice echo test
execve("/bin/echo", ["echo", "test"], [/* 40 vars */]) = 0

What you could do is:

some-zsh-function & renice $!; fg

Note that it would run that function in a subshell.

What I'm experimenting with is some way to get consistent run times for
various functions that I'm writing, so as to optimize them. It's quite educational. But the runtimes vary hugely so it's hard to say if any given change has had a
positive effect.  I was thinking that if I set the niceness to maximum,
then maybe the times would smooth out since other processes would be less likely to

Looking at the above, what I'm now doing is just:

  renice -n -20 -u root

... and then just running the function normally. It sure makes things go faster,
and it does smooth the runtimes out a bit, tho not perfectly.

Messages sorted by: Reverse Date, Date, Thread, Author