zsh-workers
 help / color / mirror / code / Atom feed
* bug: nested for loop body is executed once!
@ 2021-08-13  3:13 Daniil Iaitskov
  2021-08-13  3:47 ` Matthew Martin
  2021-08-13  3:50 ` Lawrence Velázquez
  0 siblings, 2 replies; 4+ messages in thread
From: Daniil Iaitskov @ 2021-08-13  3:13 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 778 bytes --]

Hi,

I just spot a following bug on Big Sur zsh 5.8 (x86_64-apple-darwin20.0)

$ K="1 2 3"
> $ for i in $(for j in $K; do echo "ddd/$j" ; done) ; do echo  "$i" ; done
> ddd/1
> 2
> 3
>

I would expect following output

> ddd/1
> ddd/2
> ddd/3
>

this breaks referential transparency - sorry for FP buzzwords ;)
because

$ for i in $(for j in $(echo 1 2 3); do echo "ddd/$j" ; done) ; do echo
>  "$i" ; done
>

produce expected output:

> ddd/1
> ddd/2
> ddd/3
>


I don't know if this is a feature due to some legacy optimizations.
I mostly use BASH and this behavior differs from BASH.
BASH behaves exactly as I expect.

P.S.
Wow! Are you still using just a mailing list for bug tracking?!
I hope my HTML email will be rendered correctly ;)

-- 

Best regards,
Daniil Iaitskov

[-- Attachment #2: Type: text/html, Size: 1867 bytes --]

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

end of thread, other threads:[~2021-08-14 15:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-13  3:13 bug: nested for loop body is executed once! Daniil Iaitskov
2021-08-13  3:47 ` Matthew Martin
2021-08-13  3:50 ` Lawrence Velázquez
2021-08-14 15:07   ` Daniel Shahaf

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).