From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1IcnJQ-0007sO-4T for garchives@archives.gentoo.org; Tue, 02 Oct 2007 19:21:44 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.14.1/8.14.0) with SMTP id l92JAiXm005130; Tue, 2 Oct 2007 19:10:44 GMT Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by robin.gentoo.org (8.14.1/8.14.0) with ESMTP id l92J7KBl032563 for ; Tue, 2 Oct 2007 19:07:20 GMT Received: from localhost (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 12BD7653B4 for ; Tue, 2 Oct 2007 19:07:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at gentoo.org X-Spam-Score: 0.929 X-Spam-Level: X-Spam-Status: No, score=0.929 required=5.5 tests=[AWL=-0.398, BAYES_20=-0.74, RCVD_NUMERIC_HELO=2.067] Received: from smtp.gentoo.org ([127.0.0.1]) by localhost (smtp.gentoo.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id x7aZhHPh0gTz for ; Tue, 2 Oct 2007 19:07:12 +0000 (UTC) Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTP id 0ACB865368 for ; Tue, 2 Oct 2007 19:07:10 +0000 (UTC) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Icmzy-0000rz-LU for gentoo-dev@gentoo.org; Tue, 02 Oct 2007 19:01:38 +0000 Received: from 82.153.72.179 ([82.153.72.179]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 02 Oct 2007 19:01:38 +0000 Received: from slong by 82.153.72.179 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 02 Oct 2007 19:01:38 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: gentoo-dev@lists.gentoo.org From: Steve Long Subject: [gentoo-dev] Re: Re: RFC: sh versionator.eclass Date: Tue, 02 Oct 2007 19:37:28 +0100 Message-ID: References: <200710012259.40589.uberlord@gentoo.org> <1191334716.2189.21.camel@uberlaptop.development.ltl> <1191335103.2189.22.camel@uberlaptop.development.ltl> <200710021830.26584.george@gentoo.org> <1191343930.2189.28.camel@uberlaptop.development.ltl> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@gentoo.org Reply-to: gentoo-dev@lists.gentoo.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 82.153.72.179 User-Agent: KNode/0.10.4 Sender: news X-Archives-Salt: d0c600c3-e308-459e-bf1f-1ea20ec72b56 X-Archives-Hash: 96d56eb537bba9888da2e5588c2a5987 Roy Marples wrote: > With [[ ]] you don't need to quote, which encourages people not to > bother learning when and when not to quote. > Ugh, that is so untrue imo. In #bash most people don't know [[ and use [ without quoting, as well as leaving out quotes elsewhere. Which is why we beat them over the head about quoting _all_ the time (!quotes in #bash [1]) > Regular readers of -dev will also notice a large amount of people not > quoting correctly, my view is that bash encourages this through the use > of [[ ]]. > A lot of those have been stuff like cd $S (when S could have spaces according to where the tmp dir is located) and the like, ie stuff outside [[. Honestly, [[ has got little to do with learning about quoting, since the typical case where quoting is missing is when a path is passed to a command. The thing to learn is that the shell expands everything before passing it to a command, and that spaces will lead to two parameters where you thought you had one, unless you use quotes. (ie cd "$S" ) Inside [[ is similar to assignment, in that it's down to the lex/parse (eg a=' omg spaces!'; b='oh Noes! '$a; echo "$b" # works fine -- but note what happens when you echo $b with no quotes.) kojiro knows more about the corner cases where quoting is needed in [[, but it _never_ shields you from quoting issues outside tests, and you *will* be told about it if you paste an unsafe loc in #bash. (We don't care if that's not the current problem as you see it: if you're not quoting right, your scripts are worse than useless, since they'll break when your users least expect it, for no apparent reason, and you're nowhere to be found. People soon learn not to paste unsafe expansions ;p and they get into the habit of always quoting.) [1] USE MORE QUOTES! Read http://bash-hackers.org/wiki/doku.php?id=syntax:words to understand why. http://www.grymoire.com/Unix/Quote.html will tell you how. -- Optimally, you should quote every parameter expansion ($foo). -- gentoo-dev@gentoo.org mailing list