zsh-workers
 help / color / mirror / code / Atom feed
* Very weird shell & sysread behavior
@ 2018-10-27 20:35 Sebastian Gniazdowski
  2018-10-27 20:53 ` Sebastian Gniazdowski
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Gniazdowski @ 2018-10-27 20:35 UTC (permalink / raw)
  To: Zsh hackers list

Hello,
the screenshot says it all:
http://psprint.blinkenshell.org/weird.png

In the while loop, $__tmp[-1] returns correct data.

After the loop, $__tmp[-1] nor $__tmp[@] contain any data.

More: when I provide the data (on the writing end) in following way:

        print -r -- "${(q)ZTSMAP[colsearch_pattern]}"$'\0'
        print -nr -- "${(j::)${__zts_hcw_found[@]/(#e)/--${num}-del--}}"

Then the issue occurs. But when I'll do it in following way:

        print -nr --
"${(q)ZTSMAP[colsearch_pattern]}"$'\0'"${(j::)${__zts_hcw_found[@]/(#e)/--${num}-del--}}"

I.e. through write of a single string – then the after-loop $__tmp
references contain correct data. What's going on?

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

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

* Re: Very weird shell & sysread behavior
  2018-10-27 20:35 Very weird shell & sysread behavior Sebastian Gniazdowski
@ 2018-10-27 20:53 ` Sebastian Gniazdowski
  2018-10-28  5:22   ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Gniazdowski @ 2018-10-27 20:53 UTC (permalink / raw)
  To: Zsh hackers list

Turned out the tricky output-parameter specifier, the '__tmp[(#__tmp +
1)]' isn't correct. Apparently because #__tmp in math context is
character-code. Regular __tmp_size variable and '__tmp[__tmp_size +
1]' works correctly, even when the data is printed in two print -r
instructions, not as the single string.
On Sat, 27 Oct 2018 at 22:35, Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> Hello,
> the screenshot says it all:
> http://psprint.blinkenshell.org/weird.png
>
> In the while loop, $__tmp[-1] returns correct data.
>
> After the loop, $__tmp[-1] nor $__tmp[@] contain any data.
>
> More: when I provide the data (on the writing end) in following way:
>
>         print -r -- "${(q)ZTSMAP[colsearch_pattern]}"$'\0'
>         print -nr -- "${(j::)${__zts_hcw_found[@]/(#e)/--${num}-del--}}"
>
> Then the issue occurs. But when I'll do it in following way:
>
>         print -nr --
> "${(q)ZTSMAP[colsearch_pattern]}"$'\0'"${(j::)${__zts_hcw_found[@]/(#e)/--${num}-del--}}"
>
> I.e. through write of a single string – then the after-loop $__tmp
> references contain correct data. What's going on?
>
> --
> Sebastian Gniazdowski
> News: https://twitter.com/ZdharmaI
> IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
> Blog: http://zdharma.org



-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

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

* Re: Very weird shell & sysread behavior
  2018-10-27 20:53 ` Sebastian Gniazdowski
@ 2018-10-28  5:22   ` Bart Schaefer
  2018-10-28 11:59     ` Sebastian Gniazdowski
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2018-10-28  5:22 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: zsh-workers

On Sat, Oct 27, 2018 at 1:53 PM Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> Turned out the tricky output-parameter specifier, the '__tmp[(#__tmp +
> 1)]' isn't correct. Apparently because #__tmp in math context is
> character-code. Regular __tmp_size variable and '__tmp[__tmp_size +
> 1]' works correctly, even when the data is printed in two print -r
> instructions, not as the single string.

You could also do __tmp[$#__tmp+1] if you want to avoid the extra variable.

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

* Re: Very weird shell & sysread behavior
  2018-10-28  5:22   ` Bart Schaefer
@ 2018-10-28 11:59     ` Sebastian Gniazdowski
  0 siblings, 0 replies; 4+ messages in thread
From: Sebastian Gniazdowski @ 2018-10-28 11:59 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh hackers list

On Sun, 28 Oct 2018 at 06:22, Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> On Sat, Oct 27, 2018 at 1:53 PM Sebastian Gniazdowski
> <sgniazdowski@gmail.com> wrote:
> >
> > Turned out the tricky output-parameter specifier, the '__tmp[(#__tmp +
> > 1)]' isn't correct. Apparently because #__tmp in math context is
> > character-code. Regular __tmp_size variable and '__tmp[__tmp_size +
> > 1]' works correctly, even when the data is printed in two print -r
> > instructions, not as the single string.
>
> You could also do __tmp[$#__tmp+1] if you want to avoid the extra variable.

Thanks, didn't try this. The extra variable has additional positive
effect – when increased for each 0 return from sysread, it doesn't
compute array length each read. But for 65kB reads, it probably
doesn't matter, as there will not be many of reads at all (to exhaust
the input FD).

Blinkenshell isn't responding, a more permanent and responsive link:
https://imgur.com/YGWYTLe

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org

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

end of thread, other threads:[~2018-10-28 12:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-27 20:35 Very weird shell & sysread behavior Sebastian Gniazdowski
2018-10-27 20:53 ` Sebastian Gniazdowski
2018-10-28  5:22   ` Bart Schaefer
2018-10-28 11:59     ` Sebastian Gniazdowski

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