From owner-freebsd-hackers@FreeBSD.ORG Mon May 27 19:58:29 2013 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9ECE293D for ; Mon, 27 May 2013 19:58:28 +0000 (UTC) (envelope-from linnemannr@gmail.com) Received: from mail-oa0-f43.google.com (mail-oa0-f43.google.com [209.85.219.43]) by mx1.freebsd.org (Postfix) with ESMTP id BE4CC929 for ; Mon, 27 May 2013 19:58:28 +0000 (UTC) Received: by mail-oa0-f43.google.com with SMTP id o6so9118142oag.16 for ; Mon, 27 May 2013 12:58:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=m/Lu68rN7xRYBnOV9g5MDoHpL3lch01/dFmXm8R1KqI=; b=BvQrYRDIp/Gm03zzneK4NiEQJ5A6oSsf8hZlPbLNI0xAnRaxrBaYPQxe6mQ8ajOjLm yZcer1px75/ucAyAK/+0ZoOPc++2KSXS5WPXTVqlHnyKZcpsFGxhTXC/GW+j++Txqaui FgQI+re1TUoe5XJOSWFvnRKgbeLPzyGR7bhs6QSWLmrYeWki1gbsXvWtoPfTaHeXdpZ2 jskh0cvCu3LdXhj58NKobnuuyqgPLBGhnvjlnPHQehNmWehjxuX7CKkxtLi8rSdHbTeH HvdExmxJUjMrhG98WUDCXRtD+8xMaVjzcuDTZeiXN4My7rLkXYxM4Wgw+DADUM3OlXjV caEA== MIME-Version: 1.0 X-Received: by 10.182.129.129 with SMTP id nw1mr19247765obb.100.1369684700957; Mon, 27 May 2013 12:58:20 -0700 (PDT) Received: by 10.182.251.229 with HTTP; Mon, 27 May 2013 12:58:20 -0700 (PDT) In-Reply-To: <20130527.194235.693.1@DOMY-PC> References: <20130527.194235.693.1@DOMY-PC> Date: Mon, 27 May 2013 14:58:20 -0500 Message-ID: Subject: Re: /bin/sh => STDIN & functions, var scope messing From: Reid Linnemann To: rank1seeker@gmail.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 May 2013 19:58:29 -0000 from SH(1) "Note that unlike some other shells, sh executes each process in a pipe- line with more than one command in a subshell environment and as a child of the sh process." I'm taking this to mean that redirecting to sh_f has sh_f execute in a subshell in which global_scope_var changes, but the original shell's copy is uncahnged. On Mon, May 27, 2013 at 2:42 PM, wrote: > 9.1-RELEASE-p3 > --------------- > #!/bin/sh > > sh_f () > { > global_scope_var=3D7463457 > } > > yes | sh_f > echo "$global_scope_var" > > echo ' > Now without /usr/bin/yes (maybe it is STDIN issue, instead) ?!? > ' > > sh_f > echo "$global_scope_var" > --------------- > > > Domagoj Smol=C4=8Di=C4=87 > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org= "