mattn / jvgrep

grep for japanese vimmer
https://mattn.kaoriya.net/
140 stars 19 forks source link

-A and -B options are ignored when the input is STDIN #68

Open shirayu opened 5 years ago

shirayu commented 5 years ago

This works well.

$  jvgrep -A1 vim ./README.md
./README.md:4:`jvgrep` is grep for Japanese vimmer. You can find text from files that written in another Japanese encodings.
./README.md:5:
---
./README.md:72:If you problem about output of jvgrep (ex: output of :grep command in vim), try to set $JVGREP_OUTPUT_ENCODING to specify encoding of output.
./README.md:73:
---
./README.md:87:Add following to your vimrc
./README.md:88:

However, -A and -B options are ignored when the input is STDIN.

$  cat README.md| jvgrep -A1 vim
`jvgrep` is grep for Japanese vimmer. You can find text from files that written in another Japanese encodings.
If you problem about output of jvgrep (ex: output of :grep command in vim), try to set $JVGREP_OUTPUT_ENCODING to specify encoding of output.
Add following to your vimrc
mattn commented 5 years ago

Because STDIN is not seekable.

shirayu commented 5 years ago

If jvgrep does not support these options for STDIN, how about showing a warning message and exit with some error status? I think just ignoring them is confusing.

FYI: grep supports this.

$  cat README.md| grep -A1 vim
`jvgrep` is grep for Japanese vimmer. You can find text from files that written in another Japanese encodings.

--
If you problem about output of jvgrep (ex: output of :grep command in vim), try to set $JVGREP_OUTPUT_ENCODING to specify encoding of output.

--
Add following to your vimrc
mattn commented 5 years ago

You're right. I beleived that grep doesn't support A/B for input stream.