Closed AndydeCleyre closed 1 month ago
Zero values for -ABC
turn the context option off. It's a way (the only way) to turn off when set e.g. in an alias or in a .ugrep config.
That is the same behavior as BSD grep, which does not show separators for zero context either. GNU grep may differ, but it is not standard and so there is no reason to require a separator when the context length is zero.
OK, thanks. So:
-A
completion, or is that not reproduced?Testing zsh -A
completion: it is the same as other short options. I don't see any difference. Short options don't really "complete". It's already complete except for the NUM value. As far as I can tell, zsh short option completion specifications can't indicate or suggest a NUM value. Long options do suggest that a value should be specified, but keeps it unspecified. The zsh completion specification is {-A,--after-context=-}'[Output NUM lines of trailing context after matching lines]'
, same as for -B
, -C
and similar to other options that accept arguments.
Showing group separators when there isn't any context to show is up to the grep tool to decide to support or not. It's not compatible across grep tools and should not be relied upon. BSD grep (the default macOS grep) and pcregrep/pcre2grep don't show separators for zero context.
I can change this to:
{-A,--after-context=-}'[Output NUM lines of trailing context after matching lines]:NUM:( )'
so -A
completion will just advance a space (to enter a number).
I meant that if I only provide the dash and hit tab, the A
is not suggested or listed. I can provide a screenshot when I get back to a computer.
Yes, I understood your questions that -A
did not show up and does/may not complete, so I did some tests. But with the current zsh completions (not the updated version that I mentioned) everything works fine as it should on my end:
I'm using zsh 5.8.1 (x86_64-apple-darwin21.0).
Perhaps a bug in your zsh version?
Ok, that's resolved, I just had a outdated completion files from an earlier git checkout of ugrep, but the current master works fine. Thanks!
Here's a difference from GNU grep I noticed while trying to visually separate matches -- abusing
-A
to force group separators on.It looks like busybox grep doesn't show the separators in this case either, so this may not be a goal for ugrep. But reading the
--help
descriptions suggests that separators would be shown in this case.Minor aside: It looks like the Zsh completion does not suggest the short form
-A
for some reason.