[comp.unix.wizards] csh fg %string

mrd@sun.soe.clarkson.edu (Michael DeCorte) (12/08/88)

Hello,

Given
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'

I tried evaling the previous examples but that doesn't work.  Double
quotes don't help either.  I always get one of the following:
fg: Ambiguous.
fg: No such job.

Please don't suggest that I modify the string some way, I can't.  That
includes taking subparts.

Thank you
--

Michael DeCorte // (315)265-2439 // P.O. Box 652, Potsdam, NY 13676
Internet: mrd@sun.soe.clarkson.edu  // Bitnet:   mrd@clutx.bitnet        
---------------------------------------------------------------------------
Clarkson Archive Server // commands = help, index, send, path
archive-server@sun.soe.clarkson.edu
archive-server%sun.soe.clarkson.edu@omnigate.bitnet
dumb1!dumb2!dumb3!smart!sun.soe.clarkson.edu!archive-server
---------------------------------------------------------------------------

dmk@pilot.njin.net (David Katinsky) (12/09/88)

How about
%fg %1
or
%fg %2
-- 
			      David M. Katinsky
			      
	       dmk@pilot.njin.net 	{wherever}!rutgers!dmk

maart@cs.vu.nl (Maarten Litmaath) (12/09/88)

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