From owner-freebsd-hackers@FreeBSD.ORG Mon Dec 3 17:24:29 2012 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 51F9DBB6 for ; Mon, 3 Dec 2012 17:24:29 +0000 (UTC) (envelope-from bryan-lists@shatow.net) Received: from secure.xzibition.com (secure.xzibition.com [173.160.118.92]) by mx1.freebsd.org (Postfix) with ESMTP id D76AD8FC08 for ; Mon, 3 Dec 2012 17:24:28 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=shatow.net; h=message-id :date:from:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; q=dns; s=sweb; b=YemAC1 Eb7fy0JJlCWK5tIafGyBPXz/ZENefyrTabZ8c+gC4uwabj2kg+TtPnLqZ7Pt8IUZ 1Rhn1rtMVA03ZE+4MGQmBHruxHfAa52+FrOEqd1576YebfTvmUbapQe/pN1Q4YMp qNqgMP4roGdjZ3BAfx36SKQlJXrUQHEguT7II= DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=shatow.net; h=message-id :date:from:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; s=sweb; bh=E5YhcpSW1wuv UwLJ+mCxUEGN+yg/6GLoGqwWZv/afP4=; b=R8A5GPgrDFJ0VR/IfAVjAiM8C+tk KeTAp7JaNdDIOIUQkVrqYw+xgZrRn6zFRgq8TcjjlMJ2POHjnkeIo6eXFS3TfiqA IJBRLFKHpeyUTZwV0j38P0MBTRt3SABxsY1aAdegXjTjnn6hdLkSZ2nWI/Rpvetw L43xElS0DXjfcd0= Received: (qmail 63382 invoked from network); 3 Dec 2012 11:24:21 -0600 Received: from unknown (HELO ?192.168.0.74?) (bryan@shatow.net@74.94.87.209) by sweb.xzibition.com with ESMTPA; 3 Dec 2012 11:24:21 -0600 Message-ID: <50BCE044.3050202@shatow.net> Date: Mon, 03 Dec 2012 11:24:20 -0600 From: Bryan Drewery User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: rank1seeker@gmail.com Subject: Re: $* and $@ exhibit same behaviour -> those of $* References: <20121203.170951.188.1@DOMY-PC> In-Reply-To: <20121203.170951.188.1@DOMY-PC> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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, 03 Dec 2012 17:24:29 -0000 On 12/3/2012 11:09 AM, rank1seeker@gmail.com wrote: > I've noticed this under 9.0-RELEASE-p5 > > > #!/bin/sh > ##################################################### > ftest_dot () > { > local i > > for i in $* > { > echo "$i" > } > } > > ftest_monkey () > { > local i > > for i in $@ > { > echo "$i" > } > } > >From my understanding, used in that context, they should be the same. $* Expands to the positional parameters, starting from one. When the expansion occurs within a double-quoted string it expands to a single field with the value of each parameter separated by the first character of the IFS variable, or by a space if IFS is unset. $@ Expands to the positional parameters, starting from one. When the expansion occurs within double-quotes, each positional param‐ eter expands as a separate argument. If there are no positional parameters, the expansion of @ generates zero arguments, even when @ is double-quoted. What this basically means, for example, is if $1 is “abc” and $2 is “def ghi”, then "$@" expands to the two arguments: "abc" "def ghi" Note the first sentence in both. The difference only occurs when used inside quotes, i.e. "$@" and "$*" Bryan