From: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
To: dash@vger.kernel.org
Cc: Seb <sbb@tuxfamily.org>
Subject: Re: Inconsistent behaviour between 'jobs' and 'echo "$(jobs)"'
Date: Tue, 20 Jan 2015 18:01:10 +0100 [thread overview]
Message-ID: <54BE89D6.7040101@ertelnet.rybnik.pl> (raw)
In-Reply-To: <20150120084438.GA751@ein.free.fr>
On 01/20/2015 09:44 AM, Seb wrote:
> On Mon, Jan 19, 2015 at 07:01:53PM +0100, Damian Wrobel wrote:
>
> Hello,
>
>> I'm observing an inconsistent behaviour between:
>> jobs
>> and
>> echo "$(jobs)"
>
> It's because the command is ran in a sub-shell, where there is indeed no
> running job.
>
> Bash has a special mechanism to handle this and get the current shell
> context returned, that's why you may feel some inconsistency here (like
> I myself did :)
There is an application usage [1] where this case is specifically mentioned with
a suggestion that: "For this reason, jobs is generally implemented as a shell
regular built-in."
I basically planned to use the following construction to kill all running jobs:
$ kill $(jobs -p)
Now it looks that even the following doesn't work in a dash:
$ jobs -p | xargs kill
I would prefer not to code something like the following:
$ jobs -p >/tmp/jobs-$$ && kill $(cat /tmp/jobs-$$); rm /tmp/jobs-$$
Have a nice day,
Damian
[1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/jobs.html
>
> ++
> Seb.
>
>
>
next prev parent reply other threads:[~2015-01-20 17:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-19 18:01 Inconsistent behaviour between 'jobs' and 'echo "$(jobs)"' Damian Wrobel
[not found] ` <20150120084438.GA751@ein.free.fr>
2015-01-20 17:01 ` Damian Wrobel [this message]
2015-01-20 19:07 ` Seb
2015-01-21 13:42 ` Seb
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54BE89D6.7040101@ertelnet.rybnik.pl \
--to=dwrobel@ertelnet.rybnik.pl \
--cc=dash@vger.kernel.org \
--cc=sbb@tuxfamily.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.