[comp.unix.wizards] jobs broken in csh

gwyn@brl-smoke.ARPA (Doug Gwyn ) (06/22/87)

In article <7949@brl-adm.ARPA> williams@nrl-css.arpa writes:
>% jobs | cat
>	I get nothing.

That's because the "jobs" in the pipeline is a child of the original shell,
and the child does not have job control enabled, for semi-obvious reasons.

williams@nrl-css.arpa (06/23/87)

	If I do, in csh,

% jobs > foo

	I get a file listing my jobs, but if I do

% jobs | cat

	I get nothing.  Is this a bug or a feature?  This happens on
our Gould PN 9005 and on our SUN 3s.

	The same test with other builtins (history, umask, pwd,
hashstat) gives the expected results, i.e., it acts just like a process
should, with the output both pipable and redirectable.  I can't imagine
why jobs should be special. This bug is making a shell script my
colleague wants to write a bit more klugy.

	Thanks in advance!

Jim Williams
williams@nrl-css.arpa

franco@MIKEY.BBN.COM (Frank A. Lonigro) (06/24/87)

Jim:
	I did the same test under Ultrix 1.2 and got the same results.  I
can't imagine this being a feature but it seems to be everywhere.  I looked
into the source code for the 'csh' and all builtin commands such as 'jobs'
and 'dirs' print their output to 'stdout', yet the command 'jobs | cat'
gives you nothing and 'dirs | cat' gives you the expected output.

	I didn't spend too much time on this, but I'm interested in finding
out what is happening here.  Can you Wizards enlighten us?????

thanks,
-franco%bbn.com@relay.cs.net

UUCP: through Harvard.

simon@its63b.ed.ac.uk (Simon Brown) (06/27/87)

In article <8003@brl-adm.ARPA> franco@MIKEY.BBN.COM (Frank A. Lonigro) writes:
>	I did the same test under Ultrix 1.2 and got the same results.  I
>can't imagine this being a feature but it seems to be everywhere.  I looked
>into the source code for the 'csh' and all builtin commands such as 'jobs'
>and 'dirs' print their output to 'stdout', yet the command 'jobs | cat'
>gives you nothing and 'dirs | cat' gives you the expected output.
>

The ``jobs'' command prints information about the jobs that the shell is
managing. Pipelines are executed in subshells, so ``jobs | cat'' will
print information about jobs being run by the *subshell*, not the main
shell -- and the subshell has no jobs in its table, hence no output.

	%{
	    Simon!
	%}


-- 
----------------------------------
| Simon Brown                    | UUCP:  seismo!mcvax!ukc!its63b!simon
| Department of Computer Science | JANET: simon@uk.ac.ed.its63b
| University of Edinburgh,       | ARPA:  simon%its63b.ed.ac.uk@cs.ucl.ac.uk
| Scotland, UK.                  |
----------------------------------     "Life's like that, you know"