csh fg %string

Maarten Litmaath maart at cs.vu.nl
Fri Dec 9 18:15:21 AEST 1988


mrd at sun.soe.clarkson.edu (Michael DeCorte) writes:
\host% jobs
\[1]    Stopped              foo a
\[2]    Stopped              foo b

\How can I bring either job fg by using fg %string?  I do not know what
\the difference between the two jobs are only that they are different.
\Meaning I can't do `fg %?a`.  What I would like to do is something like

\fg %foo a
\fg '%foo a'
\fg %'foo a'

How about the following?

alias	fg	'jobs > /tmp/jobs$$; set j=(\!*); set j="$j"; eval %`'\
		'grep -e $j:q < /tmp/jobs$$ > /tmp/job$$ &&'\
		'sed -n "s/.\(.\).*/\1/p" /tmp/job$$ || echo $j:q`'

Example:

	% jobs
	[1]  + Stopped              vi hhh
	[2]    Stopped              cat
	[3]  - Stopped              vi hh

Now my solution works for:

	fg
	fg -
	fg cat
	fg c.t
	fg ' hh$'
	fg \ hh$
	fg i hhh
etc.

To anybody ready to follow-up on simplifying the alias: you'd better check
if your solution doesn't choke on the `fg' examples!
-- 
fcntl(fd, F_SETFL, FNDELAY):          |Maarten Litmaath @ VU Amsterdam:
      let's go weepin' in the corner! |maart at cs.vu.nl, mcvax!botter!maart



More information about the Comp.unix.wizards mailing list