From owner-freebsd-questions Mon May 20 12:26:38 2002 Delivered-To: freebsd-questions@freebsd.org Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by hub.freebsd.org (Postfix) with ESMTP id 293C537B40D for ; Mon, 20 May 2002 12:26:17 -0700 (PDT) Received: (from dan@localhost) by dan.emsphone.com (8.12.2/8.12.3) id g4KJQEZX091932; Mon, 20 May 2002 14:26:14 -0500 (CDT) (envelope-from dan) Date: Mon, 20 May 2002 14:26:14 -0500 From: Dan Nelson To: Archie Cobbs Cc: freebsd-questions@FreeBSD.ORG Subject: Re: sh 'here document' question Message-ID: <20020520192614.GA88336@dan.emsphone.com> References: <200205201905.g4KJ5MM53848@arch20m.dellroad.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200205201905.g4KJ5MM53848@arch20m.dellroad.org> User-Agent: Mutt/1.3.99i X-OS: FreeBSD 5.0-CURRENT X-message-flag: Outlook Error Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In the last episode (May 20), Archie Cobbs said: > Is this supposed to work? It doesn't. > > $ cat foo.sh > PREFIX=foo > SUFFIX=bar > . << xxxEOFxxx > ${PREFIX}${SUFFIX}=abc > xxxEOFxxx > echo foobar=${foobar} > $ sh foo.sh > foobar= > $ I don't think it's supposed to work. A here-document basically says "instead of treating the word after << as a filename to open, just read the current script source until you hit the word, and pass that to the program's stdin". So what you end up is the command "." with "${PREFIX}${SUFFIX}=abc\n" waiting on stdin. Since "." with no args is basically a no-op, nothing happened. You are probably looking for the "eval" command, which will do variable expeansion on a line, then execute it. -- Dan Nelson dnelson@allantgroup.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message