* renice +20 %%
@ 2006-08-13 22:22 Dave Yost
2006-08-14 1:19 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Dave Yost @ 2006-08-13 22:22 UTC (permalink / raw)
To: zsh-workers
Hi.
I can't see how I would write a shell function that would do something like
renice +20 %%
I propose an option to the jobs builtin to output only the pid of the
specified job, so one could write this:
jr() { renice +20 $(jobs -x %%) }
Thanks
Dave
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: renice +20 %%
2006-08-13 22:22 renice +20 %% Dave Yost
@ 2006-08-14 1:19 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2006-08-14 1:19 UTC (permalink / raw)
To: zsh-workers
On Aug 13, 3:22pm, Dave Yost wrote:
>
> I can't see how I would write a shell function that would do something like
>
> renice +20 %%
jr() {
zmodload -i zsh/parameter
setopt localoptions noshwordsplit noksharrays extendedglob
local state
case $1 in
(%-) state=$jobstates[(R)*:-:*] ;;
(%%|%+|) state=$jobstates[(R)*:+:*] ;;
((#b)%([0-9]#)) state=$jobstates[$match] ;;
([0-9]#) renice +20 $1; return;;
esac
renice +20 ${${(s.=.)${${(s.:.)state}[3]}}[1]}
}
jobstates
This associative array gives information about the states of the
jobs currently known. The keys are the job numbers and the values
are strings of the form `JOB-STATE:MARK:PID=STATE...'. The
JOB-STATE gives the state the whole job is currently in, one of
`running', `suspended', or `done'. The MARK is `+' for the current
job, `-' for the previous job and empty otherwise. This is
followed by one `PID=STATE' for every process in the job. The PIDs
are, of course, the process IDs and the STATE describes the state
of that process.
--
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-08-14 1:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-13 22:22 renice +20 %% Dave Yost
2006-08-14 1:19 ` Bart Schaefer
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).