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 9:56 AM Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx> wrote:
On Sun, Mar 26, 2023 at 4:34 PM Jim <linux.tech.guy@xxxxxxxxx> wrote:
>
> [...] a function I am testing [...] has the following read statement which is part of a loop:
>
> for N ({0..255}) {
>   read -s -t1 -d $'\a' $'c?\e]4;'${N}$';?\a' && XC+=("$N ${c##*;}")
> }
>
> The issue is when the output of my function is piped to less.

Both the function and less read from the TTY. Which of them will
succeed when you press a key is anyone's guess.

Roman.

OK, but if the read is already completed, shouldn't less be in control?
I just added 'sleep 2' before the print statement and still see the same result.
Even if the last read didn't receive any input it should have timed out(-t1).
What am I not understanding?  Using command as follows:

cvt_256_colors_2_rgb_hex_fmt | less

Thanks for the quick response.

Jim


Messages sorted by: Reverse Date, Date, Thread, Author