[DragonFlyBSD - Bug #1397] (Feedback) jobs -l output inconsistency when called from script

bugtracker-admin at leaf.dragonflybsd.org bugtracker-admin at leaf.dragonflybsd.org
Sun May 15 05:07:47 PDT 2022


Issue #1397 has been updated by tuxillo.

Status changed from New to Feedback
Assignee set to tuxillo
% Done changed from 0 to 90

The @jobs(1)@ utility calls whatever builtin the current shell uses, or it is directly bypassed by the shell itself, example:

<pre>
$ cat /usr/bin/jobs 
#!/bin/sh
# $FreeBSD: src/usr.bin/alias/generic.sh,v 1.2 2005/10/24 22:32:19 cperciva Exp $
# $DragonFly: src/usr.bin/alias/generic.sh,v 1.3 2007/08/05 16:09:50 pavalos Exp $
# This file is in the public domain.
builtin ${0##*/} ${1+"$@"}
</pre>

And in every shell:

<pre>
$ tcsh
$ which jobs
jobs: shell built-in command.
$ sh
$ which jobs
/usr/bin/jobs
$ bash
$ which jobs
/usr/bin/jobs

</pre>

Now if you run the testjobs.sh in different shells, you might get different results, bash and sh behaving the same way:

<pre>
$ sh testjobs.sh 
[1] + 814254 Running          
$ csh testjobs.sh 
[1] 814260
[1]  + 814260 Running                       sleep 30
</pre>

Even in Solaris there is a @<command unknown>@ with the job listing, so I'd rather have not output at all.

If further comments are needed, let us know, otherwise we will close this issue.

----------------------------------------
Bug #1397: jobs -l output inconsistency when called from script
http://bugs.dragonflybsd.org/issues/1397#change-14257

* Author: Anonymous
* Status: Feedback
* Priority: Normal
* Assignee: tuxillo
* Target version: 6.4
----------------------------------------
Salute.

The jobs(1) utility gives different output when called from a script and when
from an interactive shell.

<pre>
[beket at voyager ~] cat testjobs.sh
#!/bin/sh
sleep 30 &
jobs -l
[beket at voyager ~] sh testjobs.sh 
[1] + 10005 Running           
[beket at voyager ~] sleep 30 &
[1] 10006
[beket at voyager ~] jobs -l
[1]+ 10006 Running                 sleep 30 &
[beket at voyager ~] 
</pre>

It is not clear whether the jobs(1) should work at all inside a script. POSIX
says that since it doesn't fall into the 'special' built-in category a new
environment (subshell?) would be created upon its invocation. Even this is true,
the jobs aren't specific to the shell environment, so they should be visible to
jobs(1). And in any case, the command should either print nothing or print all
the fields.

NetBSD 5.0:
<pre>
$ sh testjobs.sh 
[1] + 27159 Running           sleep 30
</pre>

SunOS 5.10:
<pre>
tuxillo at solaris$ /usr/xpg4/bin/sh testjobs.sh 
[1] + 11754      Running                 <command unknown>
</pre>

FreeBSD: same as us. (kindly reported by vstemen at #dragonflybsd).

Any thoughts ?

Best regards,
Stathis



-- 
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account



More information about the Bugs mailing list