Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: strange interaction between read command and pipe to less from function



Me again,

On Sun, Mar 26, 2023 at 10:49 AM Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx> wrote:
On Sun, Mar 26, 2023 at 5:28 PM Jim <linux.tech.guy@xxxxxxxxx> wrote:
>
> cvt_256_colors_2_rgb_hex_fmt | less

In this command both cvt_256_colors_2_rgb_hex_fmt and less are going
to read and write to the same TTY. This won't do anything useful.

Perhaps you don't realize that your `read` command reads and writes to
the TTY? What do you expect from running it simultaneously with less?

Roman.

Now I'm totally confused.  A bit by your answer and the word 'simultaneously'
as I thought the function would run first then less. That set aside I dug back
into a previous function I was working on that used the same read statement.
And yet that function when piped through less, less worked as expected. Both
functions did 'basically' the same thing  with a somewhat different output. The
one main difference was I had done a few checks before the read command
which included this:

  V=$(ps -o args= $(ps -o ppid= $$))

So I added it before the read.  Now 'less' responds as expected. I hope you
are not as confused as I am.  Especially as the command is run before the
read and not after. Also removed the sleep command.

????

Again thanks for your help,

Jim


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