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

Re: piping question



On Oct 3,  4:42pm, Mikael Magnusson wrote:
}
} echo hi there | { xterm -e 'most <& 7' 7< <(cat) }

I avoided that because I was concerned that some terminal emulators
would close all the descriptors above 2 when launching the command.

If it works, though, you can use the {varname}<& syntax to obtain
a free descriptor, and then you don't need <(cat).

    xmost() {
      set - "${(qq)@}"  # Requote command line arguments
      if [[ -t 0 ]]
      then
        xterm -g 180x30+0+0  -hold -e "most $*"
      else
        local stdin
        exec {stdin}<&0
        xterm -g 180x30+0+0  -hold -e "most $* <&$stdin"
      fi
    }

It's possible the [[ -t 0 ]] branch is extraneous with this trick, but
it seems prudent not to have xmost reading from two different ttys.



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