batgrep error with linux pipe
zhoushun123 opened this issue · comments
$ batgrep --version
batgrep 2020.10.05
$ bat -V
bat 0.16.0
$ cat setproxy.sh
export https_proxy=http://172.17.18.80:8080
export http_proxy=http://172.17.18.80:8080
export ftp_proxy=http://172.17.18.80:8080
$ cat setproxy.sh |batgrep http
────────────────────────────────────────────────────────────────────────────────
[bat error]: '<stdin>': No such file or directory (os error 2)
────────────────────────────────────────────────────────────────────────────────
Thanks for bringing this to my attention! I wasn't aware that ripgrep supported searching through stdin.
Because stdin is a pipe, it's not possible for me to share it with both ripgrep and bat. Once ripgrep reads it fully, bat has nothing left. I attempted to work around this in b5cb20c by storing the contents of stdin into a variable and piping that instead.
It comes with a couple caveats, however:
- Extremely large files will probably cause bash to run out of memory.
- I can't guarantee that it will work in every scenario.
Could you please let me know if that commit fixed it for you?
Yes,it works now,thanks.
$ cat setproxy.sh |./bat-extras/bin/batgrep http
────────────────────────────────────────────────────────────────────────────────
STDIN
1 export https_proxy=http://172.17.18.80:8080
2 export http_proxy=http://172.17.18.80:8080
3 export ftp_proxy=http://172.17.18.80:8080
────────────────────────────────────────────────────────────────────────────────
Great to hear! I'm going to close this issue, but please feel free to reopen it if you encounter anything else related to this.