RE: [Test Breakage 2.46.0-rc0] Test t0021.35 fails on NonStop
- From
rsbecker@nexbridge.com <rsbecker@nexbridge.com>
- Date
- Jul 14, 2024, 13:29 UTC
- Message-ID
- <001f01dad5f1$e518e6e0$af4ab4a0$@nexbridge.com>
- In-Reply-To
- <xmqq8qy4adl4.fsf@gitster.g>
On Saturday, July 13, 2024 10:54 PM, Junio C Hamano wrote:
Show 17 quoted lines
><rsbecker@nexbridge.com> writes: > >> ok 34 # skip delayed checkout shows progress by default on tty >> (pathspec >> checkout) (missing TTY of PERL,TTY) >> >> expecting success of 0021.35 'delayed checkout ommits progress on >> non-tty (pathspec checkout)': >> test_delayed_checkout_progress ! git checkout $opt >> >> + test_delayed_checkout_progress ! git checkout . >> test_delayed_checkout_progress: test: argument expected > >This "test: argument expected" is curious. > >The shell function reads like so and it hasn't changed since >7a132c62 (checkout: make delayed checkout respect --quiet and
--no-progress,
Show 14 quoted lines
>2021-08-26) introduced it, and there are 3 uses of "test" builtin function.
>
> test_delayed_checkout_progress () {
> if test "$1" = "!"
> then
> local expect_progress=N &&
> shift
> else
> local expect_progress=
> fi &&
>
> if test $# -lt 1
> then
> BUG "no command given totest_delayed_checkout_progress"
Show 10 quoted lines
> fi && > > ( > cd progress && > GIT_PROGRESS_DELAY=0 && > export GIT_PROGRESS_DELAY && > rm -f *.a delay-progress.log && > > "$@" 2>err && > grep "IN: smudge test-delay10.a .* \\[DELAYED\\]"
delay-progress.log
Show 11 quoted lines
>&& > if test "$expect_progress" = N > then > ! grep "Filtering content" err > else > grep "Filtering content" err > fi > ) > } > >I do not see how any of these tests can be fed a list of zero or more
argument that
Show 9 quoted lines
>causes it to barf with "argument expected", when > > test_delayed_checkout_progress ! git checkout . > >is run. The first "are we negated?" test gets > > test "!" = "!" > >and shifts that "!" away, the second test that checks the number of
arguments do
>not need any extra quoting (in other words, $# can never be an empty
string, so
Show 9 quoted lines
> > test $# -lt 1 > >cannot become "test -lt 1" that would barf, like so: > > $ ksh -c 'test -lt 1' > ksh: test: argument expected > >And whether expect_progress gets an empty string or N (we should have got N
in
>there, if the shell is so broken that the first comparison between "!" and
"!" were
>botched and the variable got assigned an empty string, or "local" were
botched and
>the variable were somehow left uninitialized, expect_progress could be a
value we
>do not expect), the last test to switch between !grep and grep can never
break like
Show 8 quoted lines
>so: > > $ ksh -c 'test = N' > ksh: test: argument expected > >because $expect_progress is inside a pair of double quotes. > >In the above "thinking out aloud", I invoked ksh because bash and dash
gives
>different error messages. > >Another remotely curious thing is that I am not sure how "local" in the
outer shell
>influences the use of the variable in the subshell >(read: now I am speculating if the above code uses some constructs that are
so
>tricky to implement correctly and an unfortunate bug gets triggered in your
shell),
>but even if such a bug caused a nonsense value to be assigned to
$expect_progress,
Show 5 quoted lines
>I do not see how it can cause "test" to barf with "argument expected". > >So, I am not sure what is going on at all. > >In any case, this does not sound anything recent. Do you know that this
used to
>work in previous releases? Could this be caused by changes in your
environment
>(like which shell is used)?
This looks like a different between ksh and bash. Under bash, the test works. I can live with that but will have to force bash to be used as the shebang #!/bin/sh defaults to ksh on this box.
Thanks for looking.
--Randall