From owner-freebsd-questions@FreeBSD.ORG Tue Mar 22 12:32:51 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2C659106564A for ; Tue, 22 Mar 2011 12:32:51 +0000 (UTC) (envelope-from rwmaillists@googlemail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id 8892D8FC13 for ; Tue, 22 Mar 2011 12:32:50 +0000 (UTC) Received: by wwc33 with SMTP id 33so8623239wwc.31 for ; Tue, 22 Mar 2011 05:32:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:date:from:to:subject:message-id:in-reply-to :references:x-mailer:mime-version:content-type :content-transfer-encoding; bh=HufOr7WANXIkFK2bTzSPD/tVGzE+xnvusLNtu+S4MHc=; b=aVPZbDv7YiTOmnNbGUM/NWhbd8RRzQwxJDIP5LKjZKnHbzdIsrPn+T6kzFCprXnu/H YTB5/F6cJvKGbj8GY/TZkeBcH5gPxb4BKL0T6/VONqALFDk+IuaIzBv8edwXVBMs4z63 ox2arRmnHf0nG2x0XjiBuMV1XQxFi07NjDpUQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=date:from:to:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=QccNpMMiS1fUPh2w1K5Qp8jMoIml/owTgF5r+ulsP9zq02qGOnUf6WWe+nMzFqzl2g xBdCQgYRqIAYpY51SIsPbsCFqhBVuKOzOpt+5VsbyW9CeAN+hEssUWaLNH9O0Qu98AZg GZRDAHlFTMGsBpXnVS2HGMPpKMUY5MVGYuA1M= Received: by 10.216.62.77 with SMTP id x55mr5109090wec.59.1300797169395; Tue, 22 Mar 2011 05:32:49 -0700 (PDT) Received: from gumby.homeunix.com (87-194-105-247.bethere.co.uk [87.194.105.247]) by mx.google.com with ESMTPS id c54sm2914940wer.30.2011.03.22.05.32.45 (version=SSLv3 cipher=OTHER); Tue, 22 Mar 2011 05:32:46 -0700 (PDT) Date: Tue, 22 Mar 2011 12:32:43 +0000 From: RW To: freebsd-questions@freebsd.org Message-ID: <20110322123243.1257e695@gumby.homeunix.com> In-Reply-To: References: <759A467E-407A-4DB8-9756-08011B5405F0@vicor.com> X-Mailer: Claws Mail 3.7.8 (GTK+ 2.22.1; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: Shell script termination with exit function in backquotes X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Mar 2011 12:32:51 -0000 On Sat, 19 Mar 2011 09:44:57 -0700 Devin Teske wrote: > At least two variations to the rule that { ... } is a block of > commands executed in the current shell are: > > 1. When the block appears as a function Is that correct? I'd assumed that functions do execute in the current shell since you can alter variables from a function, whilst you can't from a "()". e.g. -------------------------------------------------------------------- $ cat /tmp/foo #!/bin/sh f (){ x=2 } x=1 f echo $x ( x=3 ) echo $x -------------------------------------------------------------------- $ /tmp/foo 2 2