Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14975
| From | Martijn Dekker <martijn@inlv.org> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: Should [[ -v 1 ]] be supported? |
| Date | 2018-12-28 02:08 +0100 |
| 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> |
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
Re: Should [[ -v 1 ]] be supported? Martijn Dekker <martijn@inlv.org> - 2018-12-28 02:08 +0100
csiph-web