Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14975

Re: Should [[ -v 1 ]] be supported?

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Martijn Dekker <martijn@inlv.org>
Newsgroups gnu.bash.bug
Subject Re: Should [[ -v 1 ]] be supported?
Date Fri, 28 Dec 2018 02:08:19 +0100
Lines 23
Approved bug-bash@gnu.org
Message-ID <mailman.6426.1545959669.1284.bug-bash@gnu.org> (permalink)
References <CABrM6wmrn2gi8_HgmRg67B5nsgGNFRn8Bn-r20MvC-_2LJHZ0g@mail.gmail.com> <5dac2cf2-2fac-0fd1-058f-6a84a3271738@case.edu> <abd86dbc-f6e2-62bd-e9dc-f959e2dbff9f@inlv.org> <CABrM6wkGwVbPdrXTetVsFCiwDPg5JnK4KRh49WqACsKhrrMMdA@mail.gmail.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1545959669 11614 208.118.235.17 (28 Dec 2018 01:14:29 GMT)
X-Complaints-To action@cs.stanford.edu
To Peng Yu <pengyu.ut@gmail.com>, Bug reports for the GNU Bourne Again SHell <bug-bash@gnu.org>
Envelope-to bug-bash@gnu.org
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.9.1
In-Reply-To <CABrM6wkGwVbPdrXTetVsFCiwDPg5JnK4KRh49WqACsKhrrMMdA@mail.gmail.com>
Content-Language en-GB
X-detected-operating-system by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From 37.59.109.123
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14975

Show key headers only | View raw


Op 28-12-18 om 01:39 schreef Peng Yu:
> 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.

I don't believe that at all. The number of positional parameters is kept 
anyway. It's not recalculated when you compare it to another number, so 
it's just as fast as a simple comparison of two integers.

> [[ -z ${1+s} ]] does something also more than necessary too, because
> it not only tests for whether $1 is set, it also replaced with a
> string "s". This also does more than just testing whether $1 is set.

That's negligible.

And even if it weren't -- if performance is *that* important to you, 
you're using the wrong language altogether.

- M.

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Should [[ -v 1 ]] be supported? Martijn Dekker <martijn@inlv.org> - 2018-12-28 02:08 +0100

csiph-web