From owner-freebsd-questions@FreeBSD.ORG Thu Apr 4 13:26:00 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 6279F8AF for ; Thu, 4 Apr 2013 13:26:00 +0000 (UTC) (envelope-from nvass@gmx.com) Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by mx1.freebsd.org (Postfix) with ESMTP id 035EFDB for ; Thu, 4 Apr 2013 13:26:00 +0000 (UTC) Received: from mailout-eu.gmx.com ([10.1.101.216]) by mrigmx.server.lan (mrigmx002) with ESMTP (Nemesis) id 0MDSip-1UOVFx0otZ-00Gs6k for ; Thu, 04 Apr 2013 15:25:56 +0200 Received: (qmail invoked by alias); 04 Apr 2013 13:25:56 -0000 Received: from 194.219.141.124.dsl.dyn.forthnet.gr (EHLO [127.0.0.1]) [194.219.141.124] by mail.gmx.com (mp-eu016) with SMTP; 04 Apr 2013 15:25:56 +0200 X-Authenticated: #46156728 X-Provags-ID: V01U2FsdGVkX1+Af3xPk6mAC3oWEOvCnBZD4RyYCV2g/43o/QydD1 gZhTlLipD8JHiT Message-ID: <515D7F60.7000109@gmx.com> Date: Thu, 04 Apr 2013 16:25:52 +0300 From: Nikos Vassiliadis User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130215 Thunderbird/17.0.3 MIME-Version: 1.0 To: Mark Felder Subject: Re: OT: posix sh problem References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Antivirus: avast! (VPS 130404-0, 04/04/2013), Outbound message X-Antivirus-Status: Clean X-Y-GMX-Trusted: 0 Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Apr 2013 13:26:00 -0000 On 4/4/2013 3:32 μμ, Mark Felder wrote: > Hi all, > > Hopefully someone here is much more clever than I am. I've run out of > ideas on how to cleanly convert this chunk of ksh to posix sh. This is > from a BB/Hobbit/Xymon monitoring script for ZFS. I'd really like to > have this working cleanly on FreeBSD without requiring any funky shells > or using any temporary files. > > The following is supposed to be able to loop through the output of > multiple zpools reading one line at a time and each line item is set as > a variable: > > > /sbin/zpool list -H | while read name size used avail cap dedup health > altroot > do > # do interesting things here > done > > Unfortunately you can't pipe through read in posix sh. I am not sure about posix compliance but I haven't seen a bourne-like shell not supporting the "prog | while read a b c ..." syntax. FreeBSD's /bin/sh supports this. Did you mean something else, did I misunderstand your question? Nikos