From owner-freebsd-questions@FreeBSD.ORG Thu Apr 4 14:42:57 2013 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 8B315ED3; Thu, 4 Apr 2013 14:42:57 +0000 (UTC) (envelope-from feld@feld.me) Received: from new1-smtp.messagingengine.com (new1-smtp.messagingengine.com [66.111.4.221]) by mx1.freebsd.org (Postfix) with ESMTP id 5DC56751; Thu, 4 Apr 2013 14:42:57 +0000 (UTC) Received: from compute3.internal (compute3.nyi.mail.srv.osa [10.202.2.43]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 4585718D8; Thu, 4 Apr 2013 10:42:56 -0400 (EDT) Received: from frontend2.nyi.mail.srv.osa ([10.202.2.161]) by compute3.internal (MEProxy); Thu, 04 Apr 2013 10:42:56 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=feld.me; h= content-type:to:cc:subject:references:date:mime-version :content-transfer-encoding:from:message-id:in-reply-to; s= mesmtp; bh=OZ1yLFbwwkpB6nMh0/MCg31hL1g=; b=lMXKnk09bqTwjSK7QuTx2 9zQWTt/6D3gYSOmmOB/N/eDoCohL+XDrU5irNMejx+T/Vj4kIFEdIDnXLp8Na5ZF VDjdTqa8GcbGPAzM+CI8TaGnagnRj0k/jstTfiC/Xk72jhDHubmI8fcOomuBzjTd XcasUMIEZBjb8EgHBdP45A= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:to:cc:subject:references :date:mime-version:content-transfer-encoding:from:message-id :in-reply-to; s=smtpout; bh=OZ1yLFbwwkpB6nMh0/MCg31hL1g=; b=TN++ CxYarNfpvHxIN/zOl6/8BAP0VZNFFVd80KeVWmxgnaeoKqcyIg/SwKSMDuIzj2Dg JCrISLlMLilQO4fXSfdLJdVttSBg5klZ0TYiq9cfhbqSu6vWDECLD6gfGCc/jkbt reGsXNJ15vSOlJLgqfqDPokoYCWOTyazdRh4blQ= X-Sasl-enc: m+ufMBGgclcXgw7BGM6pIeQwcyjalo66gNIvDxY+GseC 1365086575 Received: from tech304.office.supranet.net (unknown [66.170.8.18]) by mail.messagingengine.com (Postfix) with ESMTPA id 86BC920009E; Thu, 4 Apr 2013 10:42:55 -0400 (EDT) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "Teske, Devin" , "Devin Teske" Subject: Re: OT: posix sh problem References: <13CA24D6AB415D428143D44749F57D7201EF2411@ltcfiswmsgmb21> Date: Thu, 04 Apr 2013 09:42:55 -0500 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable From: "Mark Felder" Message-ID: In-Reply-To: <13CA24D6AB415D428143D44749F57D7201EF2411@ltcfiswmsgmb21> User-Agent: Opera Mail/12.14 (FreeBSD) Cc: "" 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 14:42:57 -0000 On Thu, 04 Apr 2013 08:54:30 -0500, Teske, Devin = wrote: > Wait, you can't? Then I've been doing something wrong all these years=E2= =80=A6 > #!/bin/sh > printf "line1\nline2\n" | while read line > do > echo "line=3D[$line]" > done You sort-of can, but it's not portable at all. As detailed here: = http://www.etalabs.net/sh_tricks.html >> One common pitfall is trying to read output piped from commands, such= = >> as: >> foo | IFS=3D read var >>POSIX allows any or all commands in a pipeline to be run in subshells,= = >> and which command (if any) runs in the main shell varies greatly betw= een = >> implementations =E2=80=94 in particular Bash and ksh differ here. The= standard = >> idiom for overcoming this problem is to use a here document: >> >> IFS=3D read var << EOF >> $(foo) >> EOF I was having problems with the variables magically becoming empty, = remembered I had Rich's site bookmarked, checked to see if it mentioned = = and it was. I'll admit there's a high chance that due to lack of sleep = user error was the culprit.