zsh-users
 help / color / mirror / code / Atom feed
* Possible bug in 5.8
@ 2021-12-20 13:17 Simon Chatterjee
  2021-12-20 13:26 ` Dominik Vogt
  2021-12-20 13:28 ` Roman Perepelitsa
  0 siblings, 2 replies; 5+ messages in thread
From: Simon Chatterjee @ 2021-12-20 13:17 UTC (permalink / raw)
  To: zsh-users

Zsh 5.8 seems to have a problem with the variable ‘i’, in a ‘for … in’
loop, where an item being iterated over starts with a ‘/‘:

% zsh --version
zsh 5.8 (x86_64-pc-linux-gnu)
% for p in /; do echo $p; done
/
% for i in /; do echo $i; done
zsh: bad math expression: operand expected at `/‘

This isn't a problem in 5.7.1. It looks like the variable ‘i’ is
special-cased to encourage an arithmetic expression evaluation.

Is this known? If not, what’s the best way to report it?

Thanks,

Simon


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Possible bug in 5.8
  2021-12-20 13:17 Possible bug in 5.8 Simon Chatterjee
@ 2021-12-20 13:26 ` Dominik Vogt
  2021-12-20 13:28 ` Roman Perepelitsa
  1 sibling, 0 replies; 5+ messages in thread
From: Dominik Vogt @ 2021-12-20 13:26 UTC (permalink / raw)
  To: zsh-users

On Mon, Dec 20, 2021 at 01:17:53PM +0000, Simon Chatterjee wrote:
> Zsh 5.8 seems to have a problem with the variable ???i???, in a ???for ??? in???
> loop, where an item being iterated over starts with a ???/???:
>
> % zsh --version
> zsh 5.8 (x86_64-pc-linux-gnu)
> % for p in /; do echo $p; done
> /
> % for i in /; do echo $i; done
> zsh: bad math expression: operand expected at `/???

Doesn't happen with my config and 5.8.  There's most likely an
integer declaration for that variable in some file.  Look out for

  typeset -i i

or

  integer i

> This isn't a problem in 5.7.1. It looks like the variable ???i??? is
> special-cased to encourage an arithmetic expression evaluation.

Ciao

Dominik ^_^  ^_^

--

Dominik Vogt


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Possible bug in 5.8
  2021-12-20 13:17 Possible bug in 5.8 Simon Chatterjee
  2021-12-20 13:26 ` Dominik Vogt
@ 2021-12-20 13:28 ` Roman Perepelitsa
  2021-12-20 18:23   ` Daniel Shahaf
       [not found]   ` <CABA_rhDUsQCr5AfsWSiktjncjjzwd=eTb=OYhyC7p_RHvSxOgA@mail.gmail.com>
  1 sibling, 2 replies; 5+ messages in thread
From: Roman Perepelitsa @ 2021-12-20 13:28 UTC (permalink / raw)
  To: Simon Chatterjee; +Cc: Zsh Users

On Mon, Dec 20, 2021 at 2:18 PM Simon Chatterjee <jal@chatts.net> wrote:
>
> Zsh 5.8 seems to have a problem with the variable ‘i’, in a ‘for … in’
> loop, where an item being iterated over starts with a ‘/‘:
>
> % zsh --version
> zsh 5.8 (x86_64-pc-linux-gnu)
> % for p in /; do echo $p; done
> /
> % for i in /; do echo $i; done
> zsh: bad math expression: operand expected at `/‘

Works fine for me:

  % docker run --rm zshusers/zsh:5.8 zsh -c 'for i in /; do echo $i; done'
  /

Try reproducing this from `zsh -f`. If you cannot, run `typeset -p i`
in your shell. You'll probably see that it's defined. Since `zsh -f`
doesn't have this parameter, it must be defined in rc files.

Roman.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Possible bug in 5.8
  2021-12-20 13:28 ` Roman Perepelitsa
@ 2021-12-20 18:23   ` Daniel Shahaf
       [not found]   ` <CABA_rhDUsQCr5AfsWSiktjncjjzwd=eTb=OYhyC7p_RHvSxOgA@mail.gmail.com>
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Shahaf @ 2021-12-20 18:23 UTC (permalink / raw)
  To: Simon Chatterjee; +Cc: Zsh Users, Roman Perepelitsa

Roman Perepelitsa wrote on Mon, 20 Dec 2021 13:28 +00:00:
> On Mon, Dec 20, 2021 at 2:18 PM Simon Chatterjee <jal@chatts.net> wrote:
>>
>> Zsh 5.8 seems to have a problem with the variable ‘i’, in a ‘for … in’
>> loop, where an item being iterated over starts with a ‘/‘:
>>
>> % zsh --version
>> zsh 5.8 (x86_64-pc-linux-gnu)
>> % for p in /; do echo $p; done
>> /
>> % for i in /; do echo $i; done
>> zsh: bad math expression: operand expected at `/‘
>
> Works fine for me:
>
>   % docker run --rm zshusers/zsh:5.8 zsh -c 'for i in /; do echo $i; done'
>   /
>
> Try reproducing this from `zsh -f`. If you cannot, run `typeset -p i`
> in your shell. You'll probably see that it's defined. Since `zsh -f`
> doesn't have this parameter, it must be defined in rc files.

So, run «zsh -x» and look for «i» in the trace output (as a whole word).

You could try your luck with «zsh -o WARN_CREATE_GLOBAL».  It won't help
if someone _deliberately_ made «i» global, but it would catch implicit
creations of a global integer parameter (e.g., in arithmetic contexts).

The way to report bug is to post them to this list.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Possible bug in 5.8
       [not found]   ` <CABA_rhDUsQCr5AfsWSiktjncjjzwd=eTb=OYhyC7p_RHvSxOgA@mail.gmail.com>
@ 2021-12-20 18:26     ` Roman Perepelitsa
  0 siblings, 0 replies; 5+ messages in thread
From: Roman Perepelitsa @ 2021-12-20 18:26 UTC (permalink / raw)
  To: Simon Chatterjee; +Cc: Zsh Users

[cc:zsh-users] to let everyone know the problem is solved

On Mon, Dec 20, 2021 at 2:50 PM Simon Chatterjee <jal@chatts.net> wrote:
>
> Thank you! Yes this is totally user error.
>
> Simon
>
> On Mon, 20 Dec 2021 at 13:28, Roman Perepelitsa
> <roman.perepelitsa@gmail.com> wrote:
> >
> > On Mon, Dec 20, 2021 at 2:18 PM Simon Chatterjee <jal@chatts.net> wrote:
> > >
> > > Zsh 5.8 seems to have a problem with the variable ‘i’, in a ‘for … in’
> > > loop, where an item being iterated over starts with a ‘/‘:
> > >
> > > % zsh --version
> > > zsh 5.8 (x86_64-pc-linux-gnu)
> > > % for p in /; do echo $p; done
> > > /
> > > % for i in /; do echo $i; done
> > > zsh: bad math expression: operand expected at `/‘
> >
> > Works fine for me:
> >
> >   % docker run --rm zshusers/zsh:5.8 zsh -c 'for i in /; do echo $i; done'
> >   /
> >
> > Try reproducing this from `zsh -f`. If you cannot, run `typeset -p i`
> > in your shell. You'll probably see that it's defined. Since `zsh -f`
> > doesn't have this parameter, it must be defined in rc files.
> >
> > Roman.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-12-20 18:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-20 13:17 Possible bug in 5.8 Simon Chatterjee
2021-12-20 13:26 ` Dominik Vogt
2021-12-20 13:28 ` Roman Perepelitsa
2021-12-20 18:23   ` Daniel Shahaf
     [not found]   ` <CABA_rhDUsQCr5AfsWSiktjncjjzwd=eTb=OYhyC7p_RHvSxOgA@mail.gmail.com>
2021-12-20 18:26     ` Roman Perepelitsa

Code repositories for project(s) associated with this 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).