From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: "Phillip Wood" <phillip.wood123@gmail.com>,
"Đoàn Trần Công Danh" <congdanhqx@gmail.com>,
"Git List" <git@vger.kernel.org>,
"Junio C Hamano" <gitster@pobox.com>
Subject: Re: [PATCH 1/4] test-lib-functions: introduce test_line_count_cmd
Date: Fri, 25 Jun 2021 01:19:42 +0200 [thread overview]
Message-ID: <87h7hmzw37.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <CAPig+cRFjBXpm_WwSGBYu75z8TabCDZodYi=wKgTamB1a3aGmg@mail.gmail.com>
On Sun, Jun 13 2021, Eric Sunshine wrote:
> On Sun, Jun 13, 2021 at 2:18 PM Phillip Wood <phillip.wood123@gmail.com> wrote:
>> On 13/06/2021 14:28, Ævar Arnfjörð Bjarmason wrote:
>> > On Sat, Jun 12 2021, Đoàn Trần Công Danh wrote:
>> >> + { test "x$1" = "x!" && test $# = 1 ; }
>> >> [...]
>> >> + if test "x$1" = "x!"
>> >
>> > We don't use this test idiom in other places, it's OK to just use "$1" =
>> > "!". I think we're past whatever portability concern made that popular
>> > in some older shell code in the wild.
>>
>> Slightly off topic but if anyone is interested in the history of this
>> test idiom and why it is no longer needed there is a good article at
>> https://www.vidarholen.net/contents/blog/?p=1035
>
> Thanks for the link to the article; it was an interesting read.
> However, the article does seem to say that such idioms and care may
> still be warranted. In particular, the epilog gives an example which
> is still relevant on macOS today. (Indeed, I just tried it and it does
> error out as the article states.) Even discounting macOS, it also
> talks about such bugs existing as late as 2015, which isn't long ago
> by any stretch. (And, as someone whose primary -- indeed only --
> development machine is ten years old, some of the other bugs it
> mentions -- which existed as recently as ten years ago -- don't seem
> all that long ago either.)
It's only for the case where the first byte is "(" or ")" though, so
e.g. the use of this to compare things like command-line options and
other things that don't start with those characters is portable, if I'm
understanding the article correctly.
> At any rate, for those of us who are old-timers, the `"x$foo"` idiom
> is habit and only costs a couple extra characters, so I for one have
> no problem with its presence in the proposed patch.
Indeed, but it's interesting to dig and see if there's any reason for
such workarounds still.
next prev parent reply other threads:[~2021-06-24 23:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-12 4:27 [PATCH 0/4] t: new helper test_line_count_cmd Đoàn Trần Công Danh
2021-06-12 4:27 ` [PATCH 1/4] test-lib-functions: introduce test_line_count_cmd Đoàn Trần Công Danh
2021-06-13 3:10 ` Eric Sunshine
2021-06-13 7:36 ` Đoàn Trần Công Danh
2021-06-13 13:28 ` Ævar Arnfjörð Bjarmason
2021-06-13 16:37 ` Đoàn Trần Công Danh
2021-06-13 18:18 ` Phillip Wood
2021-06-13 21:42 ` Felipe Contreras
2021-06-13 23:43 ` Eric Sunshine
2021-06-14 2:56 ` Junio C Hamano
2021-06-24 23:19 ` Ævar Arnfjörð Bjarmason [this message]
2021-06-13 13:36 ` Ævar Arnfjörð Bjarmason
2021-06-14 3:01 ` Junio C Hamano
2021-06-15 15:40 ` Đoàn Trần Công Danh
2021-06-12 4:27 ` [PATCH 2/4] t6402: use find(1) builtin to filter instead of grep Đoàn Trần Công Danh
2021-06-12 4:27 ` [PATCH 3/4] t6400: use test_line_count_cmd to count # of lines in stdout Đoàn Trần Công Danh
2021-06-12 4:33 ` Bagas Sanjaya
2021-06-13 7:39 ` Đoàn Trần Công Danh
2021-06-13 3:39 ` Eric Sunshine
2021-06-13 7:42 ` Đoàn Trần Công Danh
2021-06-12 4:27 ` [PATCH 4/4] t6402: " Đoàn Trần Công Danh
2021-06-13 3:43 ` Eric Sunshine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h7hmzw37.fsf@evledraar.gmail.com \
--to=avarab@gmail.com \
--cc=congdanhqx@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=phillip.wood123@gmail.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).