tcsh fg bug?

Polytropon freebsd at edvax.de
Thu Jan 14 15:50:56 UTC 2016


On Thu, 14 Jan 2016 07:00:25 -0800 (PST), Anton Shterenlikht wrote:
> I'm using tcsh.
> 
> > jobs
> [2]  + Running                       xpdf pap.pdf
> [3]  - Running                       xautolock -time 1 -locker slock
> > fg 3
> xpdf pap.pdf (wd: ~/nobkp/out/2016/autotune)
> 
> 
> which is wrong, right?

Looks like it. :-)



> Can anybody reproduce this behaviour?

Yes:

% jobs
[1]    Suspended                     gv aaaa.ps
[2]    Suspended                     xpdf /tmp/w3dzz-antenna-iss-1-31.pdf
[3]  - Suspended                     xpdf /tmp/robe.pdf
[4]  + Suspended                     xpdf /tmp/anwenderaspekte_svm_3.3.pdf

% fg 3
xpdf /tmp/anwenderaspekte_svm_3.3.pdf




But using the correct syntax, this happens (as expected):

% fg %3
xpdf /tmp/robe.pdf



Explanation from "man csh":

       There  are  several  ways to refer to jobs in the shell.  The character
       `%' introduces a job name.  If you wish to refer to job number  1,  you
       can  name  it  as `%1'.  Just naming a job brings it to the foreground;
       thus `%1' is a synonym for `fg %1', bringing job 1 back into the  fore-
       ground.  Similarly, saying `%1 &' resumes job 1 in the background, just
       like `bg %1'.  A job can also be named by an unambiguous prefix of  the
       string  typed  in to start it: `%ex' would normally restart a suspended
       ex(1) job, if there were only one suspended job whose name  began  with
       the  string  `ex'.   It is also possible to say `%?string' to specify a
       job whose text contains string, if there is only one such job.

[...]

       fg [%job ...]
               Brings  the  specified jobs (or, without arguments, the current
               job) into the foreground, continuing each  if  it  is  stopped.
               job may be a number, a string, `', `%', `+' or `-' as described
               under Jobs.  See also the run-fg-editor editor command.


So the command

	> fg %3
	     ^

will probably do what you want. :-)



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...


More information about the freebsd-questions mailing list