Path: csiph.com!goblin3!goblin.stu.neva.ru!panix!usenet.stanford.edu!not-for-mail From: "G. Branden Robinson" Newsgroups: gnu.bash.bug Subject: Re: Should [[ -v 1 ]] be supported? Date: Thu, 27 Dec 2018 20:36:25 -0500 Lines: 57 Approved: bug-bash@gnu.org Message-ID: References: <5dac2cf2-2fac-0fd1-058f-6a84a3271738@case.edu> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ucsrfnzwexh2wzx2" X-Trace: usenet.stanford.edu 1545961030 12691 208.118.235.17 (28 Dec 2018 01:37:10 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=i5QdNQDhMZS/S7NQ7mOAVchI5fg3pjA0HAaHANo18yY=; b=IfVt++4LRPBJYh69Ck165h8v6gjyU7zow3ejw9ZxoMsM8vGXoMcwBIK2LkOTLK36fJ viTZ3xs3cWW6bMiJNs8cocmsRCmpf2Sli21ji9nnJNVY8lbJ4jjjnopXYkGHvZHX7pIq kr+tt93tFd/XUvs1X4OOoq2X0rX249SiQmKr1ffL9pONn8bWtFTnsagthAVKMW4AkADK hIDTnEsS6K7c3jro3PF7HZVd18KHacUiWl9TXnhM3ZdjNxtLinr2eD2FRc5jMu3LJCPI DBPKII4rDPajntdafOXF3e4wAsTKQujq3ZMDyWz6c6NtR0Il84pXQMonGe02l0TtsY1G LWOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=i5QdNQDhMZS/S7NQ7mOAVchI5fg3pjA0HAaHANo18yY=; b=Q890GEfX10UYd9TxVg7pK4/FNYrvpzKIui+WuRneOfXddSwj6ALyogZD4ZolgpZMly K9TWHKzxovS8IBjIf+UJ8HG0IDa9zYJPsnVl5YP1RN2miSjTsWOMusib9/OmhYxrAcK2 ImLHll7empEAx+msXtoLTKmBhxJxW3++DvmF2PUMpvvS3t+0ziFXP3qrJMUJ7VpXAizu NIy5wo9CdQ9XMHtfGUeEllACsNBmUeo5StpD2sLXDd9Ay2wFHvWEFvjfmfBcX8cJMZSx R2L1rWYSZC3QHLELXFhweozjgRYDOaZqBfKBhNlf2FKrRIlAgaWvZ5Jy5/crjTEuAsdG IY0g== X-Gm-Message-State: AJcUukf5pWxUPFEPhIbP9YitF05BTs19nwpG9nGqGgADklekASr86FmZ Xzir7P8LkazPdk/wA1VgjHSFsxtGY2w= X-Google-Smtp-Source: ALg8bN5Cwooe2NBcojyVShEqLUMQy/s0zipWhEg0nU9ZmZsDWCVlSyRM9bVI3Ec06OIWQZ9rbUMS5w== X-Received: by 2002:a25:9b04:: with SMTP id y4mr17574906ybn.182.1545960988226; Thu, 27 Dec 2018 17:36:28 -0800 (PST) Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::b31 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14977 --ucsrfnzwexh2wzx2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline At 2018-12-27T18:39:26-0600, Peng Yu wrote: > What I meant in my original email is that I want something for testing > if there is a command line argument (one or more, the exact number > does not matter). $# gives more than that info, because it tells not > only whether is any command line argument, but also how many. This > could lead to slower performance if the goal is to just test if there > is an argument. You should look into how integer comparisons are done in hardware. For instance, comparison and subtraction operations are often comparable (or even identical) in cycle count because they both perform a subtraction "under the hood". You need to be programming in assembly language to influence execution at such depths. See, e.g., https://www.quora.com/What-is-the-difference-between-cmp-and-sub-instruction-in-8086microprocessor As others have noted, if you are worried about marginal performance impacts this small, margin you are probably writing in the wrong language, or distracting yourself with tiny details when you do not even know the cyclomatic complexity of your code or the big-O classification of your algorithms. Attack those problems first, and see what you discover. Regards, Branden --ucsrfnzwexh2wzx2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEh3PWHWjjDgcrENwa0Z6cfXEmbc4FAlwlffoACgkQ0Z6cfXEm bc6nXg/7Bp8wJh+0rDs+kxy/uCX4zh0snesvEOL8A+ZN1FGDMTcdzzjGZCjKzxVY dVdrzk/xKNlYNTW7oZRpgUWL3lnxxfwVto3dxJ+nc5PSOXA3nvd6C4TapWTm3gVc ynuZEhg4S1IbHuPx8TKPFRBRpf00i6RZ1QMmWKgfzwN2ZbdR30qlc7yJlBLEcbSb 2CxFR94SBlVSOw2Jl7fwCBIrxMrABdm5f1pup6xjLqI6yhL21fFycOv6B+3Ji9pR dh5ApEkpF3FVzv7onYroAiOmrLHtC8/L2do4DmpmixpExCJTMrRyDXnmmfFzxrij Hmo8s4r3fJTzxDXM08kEULIwYzWOjgF76O/9ltfgjfnL+LFYuI8hCN1tkc5QimFw wGVkMn58SiB3FCCwxlj/hUPW2fTIbG4qgGbVFq+mNVwJREgkHBn07+eGxGq2XYcz IgSdprJOvLWJzeP5ZRIXQMqJMRSaLHEbbq+LtOVN7pmYCW42r+6GhgT3Ik2CTKT4 hwYAOVYxwvi1W4uVuGGKqOkrpmSX3ambFCDQZ7swWhKwNT+K7i1TEQ2blY4j2vFl S1SzyAAhjOTPXRxXL+3253kONjq41uP7BT2RPeCuJvI9VzYLVMX6pOMfWe+6JPIj 0WNgkaUGe3IjtszMeRWt8Elr0FV7rVvvusg4rM1o5dbQ9uQuK3s= =EvL9 -----END PGP SIGNATURE----- --ucsrfnzwexh2wzx2--