Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14974
| Path | csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Eduardo Bustamante <dualbus@gmail.com> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: Should [[ -v 1 ]] be supported? |
| Date | Thu, 27 Dec 2018 17:09:48 -0800 |
| Lines | 38 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.6425.1545959657.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" |
| X-Trace | usenet.stanford.edu 1545959658 11613 208.118.235.17 (28 Dec 2018 01:14:18 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | Martijn Dekker <martijn@inlv.org>, bug-bash <bug-bash@gnu.org> |
| To | Peng Yu <pengyu.ut@gmail.com> |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Peze9QhTt6N2EZHvxViqe5e4Z/rKoUp6I+MXxuspDos=; b=AFg3KNXmBRPw8gsCtpH27Q6V9nD9Me8ahrpEs5AuOmsmFCEWs8WjvJOgGbRrfs4+je 918Zo3ofK/rkpDDNitMgL2Rr5uKPju700mujJygwLeskCCSTjvyGDvbUWQFfYKgFIjYd c038q+rDTgSfU2eFQmRpPpC76TLkjwOoMP8V5B7oOBOIvH8hUJ/6mJovbPmfLAim2Y30 7nrLVoj2bS6TIzQvYMJAp8ieOX1INDGOVZ9k2pbbMpdYJU6fxg4NGyaFAym3LU6rRZcc wFOTUvrbhEaQ/iv1nGSblJbJkVQe70UyFpCvLK5Yp8eGfSgrD6Q6t9QNs6hLvxnab4rE PueQ== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Peze9QhTt6N2EZHvxViqe5e4Z/rKoUp6I+MXxuspDos=; b=EFC7GZt8RdqpJRI6PSOevMn1D1qaXcrgHIS61W6Zj/uWnz1NkJOzzIkn+AWPJkKbqS ACXiZBCF8nFqdWzddNQSbG3Ka2h4/0Y/A+AxkFhvMpBE0e5CRknDwITt70JdWTJwUDWw SI89NYXERPsMJ9hVDIHAr56itZ4LUMvgYdGhOCKCWqpsYD/fQ5hqZiVbnUsKjAHzgp4p VGYx3MOP2ikdLBgWHBb5QasKNxocqzoICUw7zVJcU+hDNQGBF6T/kHv6mB0GF7wq7V6y 2RQVYt2JXKZCAS9wtLgDlqo+QZEi2LwXb9z/nQONfiFtbxwc65qyaY/1Qf9bdENsUyqp uNrA== |
| X-Gm-Message-State | AA+aEWYeYNoPuvRQYHVMxy364tde7DEJy2Rf9q350o2TCuQskbCPnT99 JtPV3jq7JOWlsluBsp7aDbkaAl76POezJGHnK2k= |
| X-Google-Smtp-Source | AFSGD/XiVMZJtQH7OcrMRnnsqCLAMfeoCHALgFFseeMy+Xx530QXJoUZo2VvYDpA3kSvcpmqs/KVeTXrw43OFeCbcqk= |
| X-Received | by 2002:a19:f813:: with SMTP id a19mr12428503lff.67.1545959401816; Thu, 27 Dec 2018 17:10:01 -0800 (PST) |
| In-Reply-To | <CABrM6wkGwVbPdrXTetVsFCiwDPg5JnK4KRh49WqACsKhrrMMdA@mail.gmail.com> |
| X-detected-operating-system | by eggs.gnu.org: Genre and OS details not recognized. |
| X-Received-From | 2a00:1450:4864:20::12d |
| 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:14974 |
Show key headers only | View raw
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 gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: Should [[ -v 1 ]] be supported? Eduardo Bustamante <dualbus@gmail.com> - 2018-12-27 17:09 -0800
csiph-web