Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!uwmcsd1!marque!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!maart
From: maart@cs.vu.nl (Maarten Litmaath)
Newsgroups: comp.unix.wizards
Subject: Re: csh fg %string
Message-ID: <1788@solo7.cs.vu.nl>
Date: 9 Dec 88 08:15:21 GMT
References: 
Organization: V.U. Informatica, Amsterdam, the Netherlands
Lines: 42

mrd@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@cs.vu.nl, mcvax!botter!maart