Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Jan 2022 16:28:43 -0500
From:      Vlad Markov <dvoich@optonline.net>
To:        questions@freebsd.org
Subject:   Re: Piping jobs output
Message-ID:  <20220112162843.6a383da1f31c934f0e96e45b@optonline.net>
In-Reply-To: <Yd8z6haDopLrG2C7@digitalcombine.ca>
References:  <Yd8z6haDopLrG2C7@digitalcombine.ca>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 12 Jan 2022 14:02:50 -0600
Ron Wills <ron@digitalcombine.ca> wrote:

> I have a number of shell scripts that scan various directories
> updating files. They can be quite time consuming so I put
> parts of the operations in the background and use "jobs" to
> manage how many things I put in the background. With bash
> this work beautifully but with FreeBSD's /bin/sh it's broken.
> 
> So here's how I've been doing things:
> 
> How I count the number of jobs I have in the background:
> jobs | wc -l
> 
> In my scanning loop, to limit the jobs I create I have:
> while [ "$(jobs | wc -l)" -ge 4 ]; do
>   sleep 2
> done
> 
> In /bin/sh the piping of jobs output doesn't seem to work.
> 
> This lists all the jobs:
> jobs
> 
> This always returns 0:
> jobs | wc -l
> 
> The just returns an empty line:
> jobs | cat
> 
> I don't know if I've stumbled on a bug or feature. I haven't
> seen anything that says I can't pipe the output of builtin
> commands in sh. 
> 
> This is on the lastest version FreeBSD 13.
> 
Why not just install bash from the ports collection?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20220112162843.6a383da1f31c934f0e96e45b>