Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14974 > unrolled thread
| Started by | Eduardo Bustamante <dualbus@gmail.com> |
|---|---|
| First post | 2018-12-27 17:09 -0800 |
| Last post | 2018-12-27 17:09 -0800 |
| 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.
Re: Should [[ -v 1 ]] be supported? Eduardo Bustamante <dualbus@gmail.com> - 2018-12-27 17:09 -0800
| From | Eduardo Bustamante <dualbus@gmail.com> |
|---|---|
| Date | 2018-12-27 17:09 -0800 |
| Subject | Re: Should [[ -v 1 ]] be supported? |
| Message-ID | <mailman.6425.1545959657.1284.bug-bash@gnu.org> |
On Thu, Dec 27, 2018 at 4:50 PM Peng Yu <pengyu.ut@gmail.com> 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.
>
> [[ -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.
>
> So both cases would be slower than [[ -v 1 ]] if it were supported.
>
> As of now, because (($#)) or [[ -z ${1+s} ]] are not consistently
> faster than the other, there is no way to write a program that is
> consistently fastest. To achieve this goal, one has to implement [[ -v
> 1 ]] or something similar that just test whether $1 but no more.
Out of curiosity: What kind of software are you writing in bash that
you invest so much time in shaving those extra micro-seconds?
a) If you're doing this for fun, then I think you might understand why
it might be counter-productive to bloat Bash for a use case that is
uncommon?
b) If you're building real-world applications in bash that require
that level of performance, can you share what these applications do on
a general level and why you chose bash as the run-time? When arguing
for a feature, I think that explaining the expected use cases make a
much better argument.
Also, why do you expect an unimplemented feature to be a better option
to achieve more performance than two implementations that are already
available and can benefit from some optimizations?
Back to top | Article view | gnu.bash.bug
csiph-web