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


Groups > gnu.bash.bug > #14975 > unrolled thread

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

Started byMartijn Dekker <martijn@inlv.org>
First post2018-12-28 02:08 +0100
Last post2018-12-28 02:08 +0100
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#14975 — Re: Should [[ -v 1 ]] be supported?

FromMartijn Dekker <martijn@inlv.org>
Date2018-12-28 02:08 +0100
SubjectRe: Should [[ -v 1 ]] be supported?
Message-ID<mailman.6426.1545959669.1284.bug-bash@gnu.org>
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.

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web