From owner-freebsd-stable@FreeBSD.ORG Thu Jun 1 15:39:08 2006 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A6E4716A578 for ; Thu, 1 Jun 2006 15:39:08 +0000 (UTC) (envelope-from joseph.koshy@gmail.com) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.172]) by mx1.FreeBSD.org (Postfix) with ESMTP id E379143D4C for ; Thu, 1 Jun 2006 15:39:05 +0000 (GMT) (envelope-from joseph.koshy@gmail.com) Received: by ug-out-1314.google.com with SMTP id m3so176423uge for ; Thu, 01 Jun 2006 08:39:04 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=X7QmpVJocbL09pMiKyrNm6UDDevIFezknBYToJhoJyfQHXv58dnNpDfuZXA23hXvyWDAxX3C+KXzg1Ge5t8/LnQnMAYt+q+PeWZFOexLmeinJp0jG25gsGdFRTvYk4EhadKiN8wXQqLwcH6mkzDjYX59YqNk9UgcXhg78Ectegw= Received: by 10.78.18.1 with SMTP id 1mr148465hur; Thu, 01 Jun 2006 08:13:46 -0700 (PDT) Received: by 10.78.71.19 with HTTP; Thu, 1 Jun 2006 08:13:45 -0700 (PDT) Message-ID: <84dead720606010813u5c5a3f6fo75c19b7f02e87f18@mail.gmail.com> Date: Thu, 1 Jun 2006 20:43:45 +0530 From: "Joseph Koshy" To: "Michael Schuh" In-Reply-To: <1dbad3150606010728l379e4c23p1a77558800498806@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1dbad3150606010728l379e4c23p1a77558800498806@mail.gmail.com> Cc: freebsd-hackers@freebsd.org, freebsd-stable@freebsd.org Subject: Re: Scope of Variables in sh X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jun 2006 15:39:08 -0000 > but this doesnt function right. so i see the behavior from > $myline in the while-loop like an local variable...... If you are looking for function local variables, use the "local" keyword. For example: ++++ a.sh ++++ a=1 f() { local a a=2 echo B: In f: $a } echo A: Outside f: $a f echo C: Outside f: $a ++++++++ % sh a.sh A: Outside f: 1 B: In f: 2 C: Outside f: 1 -- FreeBSD Volunteer, http://people.freebsd.org/~jkoshy