* Boundary error in VCS_INFO_set --nvcs
@ 2022-04-13 21:34 Bart Schaefer
2022-04-17 18:04 ` Daniel Shahaf
0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2022-04-13 21:34 UTC (permalink / raw)
To: Zsh hackers list
This output is from an older version of VCS_INFO but I don't see a
diff that would have changed anything but line numbers:
+vcs_info:52> VCS_INFO_set --nvcs
+VCS_INFO_set:5> setopt localoptions noksharrays NO_shwordsplit
+VCS_INFO_set:6> local -i i j
+VCS_INFO_set:8> [[ --nvcs == --nvcs ]]
+VCS_INFO_set:9> [[ '' == -preinit- ]]
+VCS_INFO_set:10> i=0
+VCS_INFO_set:11> typeset -gx 'vcs_info_msg_0_='
+VCS_INFO_set:10> i=-1
+VCS_INFO_set:11> typeset -gx 'vcs_info_msg_-1_='
VCS_INFO_set:typeset:11: not valid in this context: vcs_info_msg_-1_
The problem is that when disable-patterns matches the current
directory, vcs_info invokes VCS_INFO_set --nvcs, which hits this loop:
if [[ $1 == '--nvcs' ]] ; then
[[ $2 == '-preinit-' ]] && (( maxexports == 0 )) && (( maxexports = 1 ))
for i in {0..$((maxexports - 1))} ; do
Because $2 is not "-preeinit-", when maxexports is zero it is never
reset to 1 and the "for" loop runs backwards to -1. I don't otherwise
know how to reproduce the situation where VCS_INFO_maxexports is never
called.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Boundary error in VCS_INFO_set --nvcs
2022-04-13 21:34 Boundary error in VCS_INFO_set --nvcs Bart Schaefer
@ 2022-04-17 18:04 ` Daniel Shahaf
2022-04-17 18:48 ` Daniel Shahaf
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Shahaf @ 2022-04-17 18:04 UTC (permalink / raw)
To: zsh-workers
Bart Schaefer wrote on Wed, Apr 13, 2022 at 14:34:28 -0700:
> This output is from an older version of VCS_INFO but I don't see a
> diff that would have changed anything but line numbers:
>
> +vcs_info:52> VCS_INFO_set --nvcs
> +VCS_INFO_set:5> setopt localoptions noksharrays NO_shwordsplit
> +VCS_INFO_set:6> local -i i j
> +VCS_INFO_set:8> [[ --nvcs == --nvcs ]]
> +VCS_INFO_set:9> [[ '' == -preinit- ]]
> +VCS_INFO_set:10> i=0
> +VCS_INFO_set:11> typeset -gx 'vcs_info_msg_0_='
> +VCS_INFO_set:10> i=-1
> +VCS_INFO_set:11> typeset -gx 'vcs_info_msg_-1_='
> VCS_INFO_set:typeset:11: not valid in this context: vcs_info_msg_-1_
>
> The problem is that when disable-patterns matches the current
> directory, vcs_info invokes VCS_INFO_set --nvcs, which hits this loop:
>
> if [[ $1 == '--nvcs' ]] ; then
> [[ $2 == '-preinit-' ]] && (( maxexports == 0 )) && (( maxexports = 1 ))
> for i in {0..$((maxexports - 1))} ; do
>
> Because $2 is not "-preeinit-", when maxexports is zero it is never
> reset to 1 and the "for" loop runs backwards to -1. I don't otherwise
> know how to reproduce the situation where VCS_INFO_maxexports is never
> called.
Can't reproduce. What's $ZSH_PATCHLEVEL? Could you try in 'zsh -f' in
a new directory (create a new repository therein)?
Cheers,
Daniel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Boundary error in VCS_INFO_set --nvcs
2022-04-17 18:04 ` Daniel Shahaf
@ 2022-04-17 18:48 ` Daniel Shahaf
2022-04-17 21:31 ` Bart Schaefer
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Shahaf @ 2022-04-17 18:48 UTC (permalink / raw)
To: zsh-workers
Daniel Shahaf wrote on Sun, Apr 17, 2022 at 18:04:23 +0000:
> Bart Schaefer wrote on Wed, Apr 13, 2022 at 14:34:28 -0700:
> > This output is from an older version of VCS_INFO but I don't see a
> > diff that would have changed anything but line numbers:
> >
> > +vcs_info:52> VCS_INFO_set --nvcs
> > +VCS_INFO_set:5> setopt localoptions noksharrays NO_shwordsplit
> > +VCS_INFO_set:6> local -i i j
> > +VCS_INFO_set:8> [[ --nvcs == --nvcs ]]
> > +VCS_INFO_set:9> [[ '' == -preinit- ]]
> > +VCS_INFO_set:10> i=0
> > +VCS_INFO_set:11> typeset -gx 'vcs_info_msg_0_='
> > +VCS_INFO_set:10> i=-1
> > +VCS_INFO_set:11> typeset -gx 'vcs_info_msg_-1_='
> > VCS_INFO_set:typeset:11: not valid in this context: vcs_info_msg_-1_
> >
> > The problem is that when disable-patterns matches the current
> > directory, vcs_info invokes VCS_INFO_set --nvcs, which hits this loop:
> >
> > if [[ $1 == '--nvcs' ]] ; then
> > [[ $2 == '-preinit-' ]] && (( maxexports == 0 )) && (( maxexports = 1 ))
> > for i in {0..$((maxexports - 1))} ; do
> >
> > Because $2 is not "-preeinit-", when maxexports is zero it is never
> > reset to 1 and the "for" loop runs backwards to -1. I don't otherwise
> > know how to reproduce the situation where VCS_INFO_maxexports is never
> > called.
>
> Can't reproduce. What's $ZSH_PATCHLEVEL? Could you try in 'zsh -f' in
> a new directory (create a new repository therein)?
Found a(nother?) way. In current HEAD and 'zsh -f', call vcs_info once,
_then_ set «zstyle ':vcs_info:*' enable none», and the error will happen
via the following callsite:
96 if [[ -n ${(M)enabled:#(#i)none} ]] ; then
97 [[ -n ${vcs_info_msg_0_} ]] && VCS_INFO_set --nvcs
98 return 0
99 fi
The documentation of the «nvcsformats» style makes it clear that in the
"no VCS" case vcs_info_msg_0_ should still get set.
I'm not sure, however, what the right code change is. Anyone wants to
jump in?
This is not a regression, and as such not a blocker.
Cheers,
Daniel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Boundary error in VCS_INFO_set --nvcs
2022-04-17 18:48 ` Daniel Shahaf
@ 2022-04-17 21:31 ` Bart Schaefer
0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2022-04-17 21:31 UTC (permalink / raw)
To: Daniel Shahaf; +Cc: Zsh hackers list
On Sun, Apr 17, 2022 at 11:48 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
>
> > Bart Schaefer wrote on Wed, Apr 13, 2022 at 14:34:28 -0700:
> > > [[ $2 == '-preinit-' ]] && (( maxexports == 0 )) && (( maxexports = 1 ))
> > > for i in {0..$((maxexports - 1))} ; do
>
> I'm not sure, however, what the right code change is. Anyone wants to
> jump in?
Dropping [[ $2 == '-preinit-' ]] && would be the obvious thing, but
I'm not sure why we care about it, so perhaps something more
complicated is required.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-04-17 21:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-13 21:34 Boundary error in VCS_INFO_set --nvcs Bart Schaefer
2022-04-17 18:04 ` Daniel Shahaf
2022-04-17 18:48 ` Daniel Shahaf
2022-04-17 21:31 ` Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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 NNTP newsgroup(s).