From: "Lawrence Velázquez" <larryv@zsh.org>
To: Jim <linuxtechguy@gmail.com>
Cc: "Roman Perepelitsa" <roman.perepelitsa@gmail.com>, zsh-users@zsh.org
Subject: Re: strange interaction between read command and pipe to less from function
Date: Sun, 26 Mar 2023 19:50:33 -0400 [thread overview]
Message-ID: <0ee9e5cd-1595-459f-89ed-e1ca4f4f297c@app.fastmail.com> (raw)
In-Reply-To: <CAN=4vMq41u31dp6fnOQ=bYCSsVGWMVPZMenHVS=XaxffZ8ASpg@mail.gmail.com>
On Sun, Mar 26, 2023, at 1:23 PM, Roman Perepelitsa wrote:
> On Sun, Mar 26, 2023 at 7:04 PM Jim <linux.tech.guy@gmail.com> wrote:
>>
>> Now I'm totally confused. A bit by your answer and the word 'simultaneously'
>> as I thought the function would run first then less.
>
> When you run `cvt_256_colors_2_rgb_hex_fmt | less`, two processes run
> simultaneously. One is executing `cvt_256_colors_2_rgb_hex_fmt`, the
> other is executing `less`.
A demonstration:
% foo() for arg do print -n $arg >$TTY; done
% repeat 10 do foo {a..j} | foo {0..9}; echo; done
0ab1c2d3e4f5gh6i7j89
0a1b2c3de4f5g6h7i8j9
01a2b3c4d5e6fg7h8i9j
0a1bc2de3fgh4ij56789
01ab2c3d4e5f6g78h9ij
01a2b34c56d78e9fghij
0a1bc2de3fgh4ij56789
ab0cd1ef2gh3ij456789
a0bc1d2e3f4g5h6i7j89
0ab1c2d3ef4gh5i6j789
Note the nondeterministic output.
--
vq
prev parent reply other threads:[~2023-03-26 23:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-26 14:33 Jim
2023-03-26 14:55 ` Roman Perepelitsa
2023-03-26 15:28 ` Jim
2023-03-26 15:49 ` Roman Perepelitsa
2023-03-26 17:04 ` Jim
2023-03-26 17:23 ` Roman Perepelitsa
2023-03-26 23:50 ` Lawrence Velázquez [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0ee9e5cd-1595-459f-89ed-e1ca4f4f297c@app.fastmail.com \
--to=larryv@zsh.org \
--cc=linuxtechguy@gmail.com \
--cc=roman.perepelitsa@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).