[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Should [[ -v 1 ]] be supported?
From: |
Eduardo Bustamante |
Subject: |
Re: Should [[ -v 1 ]] be supported? |
Date: |
Thu, 27 Dec 2018 17:09:48 -0800 |
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?
- Should [[ -v 1 ]] be supported?, Peng Yu, 2018/12/26
- Re: Should [[ -v 1 ]] be supported?, Chet Ramey, 2018/12/27
- Re: Should [[ -v 1 ]] be supported?, Martijn Dekker, 2018/12/27
- Re: Should [[ -v 1 ]] be supported?, Peng Yu, 2018/12/27
- Re: Should [[ -v 1 ]] be supported?,
Eduardo Bustamante <=
- Re: Should [[ -v 1 ]] be supported?, Martijn Dekker, 2018/12/27
- Re: Should [[ -v 1 ]] be supported?, Peng Yu, 2018/12/27
- Re: Should [[ -v 1 ]] be supported?, G. Branden Robinson, 2018/12/27
- Re: Should [[ -v 1 ]] be supported?, Eduardo Bustamante, 2018/12/27
- Re: Should [[ -v 1 ]] be supported?, Chet Ramey, 2018/12/28
- Re: Should [[ -v 1 ]] be supported?, G. Branden Robinson, 2018/12/27
- Re: Should [[ -v 1 ]] be supported?, Peng Yu, 2018/12/27
- Re: Should [[ -v 1 ]] be supported?, G. Branden Robinson, 2018/12/27
- Re: Should [[ -v 1 ]] be supported?, Peng Yu, 2018/12/28
- Re: Should [[ -v 1 ]] be supported?, Eduardo Bustamante, 2018/12/28