From nobody Wed Jan 12 21:28:43 2022 X-Original-To: questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 281F21959401 for ; Wed, 12 Jan 2022 21:28:54 +0000 (UTC) (envelope-from dvoich@optonline.net) Received: from cmx-alt-rgout005.mx-altice.prod.cloud.synchronoss.net (cmx-alt-rgout005.mx-altice.prod.cloud.synchronoss.net [65.20.48.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4JZ10443K7z4nr9 for ; Wed, 12 Jan 2022 21:28:52 +0000 (UTC) (envelope-from dvoich@optonline.net) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=optonline.net; s=dkim-002; t=1642022932; bh=oilHrCEdtOKAZdzkp+F80W/x/HMniSL8prizzPyQ1nI=; h=Date:From:To:Subject:Message-Id:In-Reply-To:References:Mime-Version:Content-Type; b=D6xIjSkclph6PUV6mGDAeAIoeWXcRq59jMli6T9bs5s3sZ6gKtU9oEirIyf6Gi9Cw7flWhr6GeLXtStqeX9HwvjmgTad9GNB3ElZxqyNwSRAR88eAddoXaTK8AN3avH9xv4zVnOEUgm+b/ZmGENAuocV82/T14QLtynSc602yZ7vGEa2qAaZSDeTZDc3+o+2jbCbZObNauuOWNvBszjBmPxkgK4TXEVdx4q+K8TBfw57v07GeL4Hyrpum3JgAAAHP3pYH8ONdmGf1TmEZDhFjIPWQ9f3MCYl1njjFTJPb25uCk/i0kmZmEN9uotP95v2+zXPYGpylvwfHQwvo9Bt7w== X-RG-VS-CS: clean X-RG-VS-SC: 0 X-RG-VS: Clean X-Originating-IP: [24.185.145.223] X-RG-Env-Sender: dvoich@optonline.net X-RG-Rigid: 619B5DC6013836E2 X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvvddrtddugdduvdehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecutefnvffkvefgfgfupdggtfgfnhhsuhgsshgtrhhisggvpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfgjfhfogggtgfesthejredtjfdtvdenucfhrhhomhepgghlrgguucforghrkhhovhcuoeguvhhoihgthhesohhpthhonhhlihhnvgdrnhgvtheqnecuggftrfgrthhtvghrnhepgfelueekhfegvddtteevhfekhfffueeftddtkeetvedulefgueduudehhfejhfetnecukfhppedvgedrudekhedrudeghedrvddvfeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhephhgvlhhopehhrghpphihrdgufigrrhhfjedrnhgvthdpihhnvghtpedvgedrudekhedrudeghedrvddvfedpmhgrihhlfhhrohhmpeguvhhoihgthhesohhpthhonhhlihhnvgdrnhgvthdpnhgspghrtghpthhtohepuddprhgtphhtthhopehquhgvshhtihhonhhssehfrhgvvggsshgurdhorhhg X-RazorGate-Vade-Verdict: clean 0 X-RazorGate-Vade-Classification: clean Received: from happy.dwarf7.net (24.185.145.223) by cmx-alt-rgout005.mx-altice.prod.cloud.synchronoss.net (5.8.805) id 619B5DC6013836E2 for questions@freebsd.org; Wed, 12 Jan 2022 21:28:45 +0000 Date: Wed, 12 Jan 2022 16:28:43 -0500 From: Vlad Markov To: questions@freebsd.org Subject: Re: Piping jobs output Message-Id: <20220112162843.6a383da1f31c934f0e96e45b@optonline.net> In-Reply-To: References: X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; amd64-portbld-freebsd13.0) List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4JZ10443K7z4nr9 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=optonline.net header.s=dkim-002 header.b=D6xIjSkc; dmarc=none; spf=pass (mx1.freebsd.org: domain of dvoich@optonline.net designates 65.20.48.24 as permitted sender) smtp.mailfrom=dvoich@optonline.net X-Spamd-Result: default: False [-2.00 / 15.00]; RCVD_TLS_LAST(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[optonline.net:s=dkim-002]; HAS_XOIP(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_FROM(0.00)[optonline.net]; MV_CASE(0.50)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; DMARC_NA(0.00)[optonline.net]; RCPT_COUNT_ONE(0.00)[1]; DWL_DNSWL_LOW(-1.00)[optonline.net:dkim]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_TRACE(0.00)[optonline.net:+]; NEURAL_SPAM_LONG(1.00)[1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; R_SPF_ALLOW(-0.20)[+ip4:65.20.48.0/24]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[optonline.net]; ASN(0.00)[asn:16509, ipnet:65.20.48.0/24, country:US]; RCVD_COUNT_TWO(0.00)[2]; MID_RHS_MATCH_FROM(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[24.185.145.223:received] X-ThisMailContainsUnwantedMimeParts: N On Wed, 12 Jan 2022 14:02:50 -0600 Ron Wills 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?