From nobody Thu Jan 13 15:07:40 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 CBC81195AD19 for ; Thu, 13 Jan 2022 15:07:55 +0000 (UTC) (envelope-from ron@digitalcombine.ca) Received: from hadesmail.canspace.ca (hadesmail.canspace.ca [142.44.129.205]) (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 4JZSV2489Vz4tK6 for ; Thu, 13 Jan 2022 15:07:54 +0000 (UTC) (envelope-from ron@digitalcombine.ca) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=digitalcombine.ca; s=default; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=9fBUwqBaDu/mKmk4LI1CXxGxJ2Xa5HVpwPy+euPRdRY=; b=jdubkKrA3mxrfLtKiSd0huziE8 49pdo+8pahmU75yPI90Rd8SZiOZwsgUPdr4e57kO3y/W5535idLidg3jhBmzhUR6K49jKjCLUDYSz jZv9irse7UW5HtaB3JFjkULHN3gA7MRxKu0gRvL64mX/k7oqzUcZ2pwPAP3wFzAmgKOrINhc9Cn+Y JmMUFQbIr4i4ZE24Lmo+cO447XioDBf+i30cXvfrnFOSFAVa9eJanEF8bKQ5T4gyb9LtqDIijKspb 9ocmB6i2G0UDk44SjHVWT3Thg23D/HwtxrmG5i8dJRX8Bnp23+dg6bjietDgIB5BBJ0QtW5J413KC Eff2IqQQ==; Received: from [64.201.200.14] (port=34176 helo=digitalcombine.ca) by hades.canspace.ca with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n81hd-00079K-4d for questions@freebsd.org; Thu, 13 Jan 2022 10:07:53 -0500 Date: Thu, 13 Jan 2022 09:07:40 -0600 From: Ron Wills To: questions@freebsd.org Subject: Re: Piping jobs output Message-ID: <20220113150740.GA57053@digitalcombine.ca> Mail-Followup-To: questions@freebsd.org References: <20220112162843.6a383da1f31c934f0e96e45b@optonline.net> 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=utf-8 Content-Disposition: inline In-Reply-To: <20220112162843.6a383da1f31c934f0e96e45b@optonline.net> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hades.canspace.ca X-AntiAbuse: Original Domain - freebsd.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - digitalcombine.ca X-Get-Message-Sender-Via: hades.canspace.ca: authenticated_id: ron@digitalcombine.ca X-Authenticated-Sender: hades.canspace.ca: ron@digitalcombine.ca X-Source: X-Source-Args: X-Source-Dir: X-Rspamd-Queue-Id: 4JZSV2489Vz4tK6 X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=pass header.d=digitalcombine.ca header.s=default header.b=jdubkKrA; dmarc=none; spf=pass (mx1.freebsd.org: domain of ron@digitalcombine.ca designates 142.44.129.205 as permitted sender) smtp.mailfrom=ron@digitalcombine.ca X-Spamd-Result: default: False [-0.11 / 15.00]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[digitalcombine.ca:s=default]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; HAS_X_SOURCE(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; ARC_NA(0.00)[]; NEURAL_SPAM_MEDIUM(1.00)[1.000]; RCPT_COUNT_ONE(0.00)[1]; DMARC_NA(0.00)[digitalcombine.ca]; R_SPF_ALLOW(-0.20)[+ip4:142.44.129.205]; DKIM_TRACE(0.00)[digitalcombine.ca:+]; NEURAL_HAM_SHORT(-0.61)[-0.607]; HAS_X_GMSV(0.00)[ron@digitalcombine.ca]; MLMMJ_DEST(0.00)[questions]; HAS_X_ANTIABUSE(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:16276, ipnet:142.44.128.0/17, country:FR]; RCVD_COUNT_TWO(0.00)[2]; HAS_X_AS(0.00)[ron@digitalcombine.ca]; RECEIVED_SPAMHAUS_PBL(0.00)[64.201.200.14:received] X-ThisMailContainsUnwantedMimeParts: N On Wed, Jan 12, 2022 at 04:28:43PM -0500, Vlad Markov wrote: > 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. > > > Why not just install bash from the ports collection? > This is what I have done for the time being but I do find this to be rather strange behaviour from sh. Maybe this isn't the mailing list for this but this test script demonstrates the problem. for ITEM in 1 2 3 4 5 6 7 8 9; do echo "JOB: $ITEM" # Limit it to three jobs while [ "$(jobs | wc -l)" -ge 3 ]; do sleep 2 done # Show jobs stats jobs echo " number of jobs = $(jobs | wc -l)" jobs | cat sleep 5 & done With bash only 3 jobs will run at a time. With sh it runs all 9 jobs without hesitation. After doing some further testing it seems that jobs is the only builtin command that I can't pipe the output of. -- Ron Wills https://www.digitalcombine.ca Open Source & The Command Line