Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: strange interaction between read command and pipe to less from function
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@xxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author