Use grep -F when no argument is passed (literal string match)
Why? Most users who pass the current selection to grep likely do not intend to pass the selection as a regex input string. This makes the grepcmd use an additional -F flag to perform literal-string matching for the current selection. The -F flag seems to be the standard flag for literal-string matching in every grep implementation I've found.
This commit is contained in:
parent
019fbc5439
commit
4d9b853561
|
@ -7,9 +7,10 @@ declare-option -hidden int grep_current_line 0
|
||||||
define-command -params .. -docstring %{
|
define-command -params .. -docstring %{
|
||||||
grep [<arguments>]: grep utility wrapper
|
grep [<arguments>]: grep utility wrapper
|
||||||
All optional arguments are forwarded to the grep utility
|
All optional arguments are forwarded to the grep utility
|
||||||
|
Passing no argument will perform a literal-string grep for the current selection
|
||||||
} grep %{ evaluate-commands %sh{
|
} grep %{ evaluate-commands %sh{
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
set -- "${kak_selection}"
|
set -- -F "${kak_selection}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-grep.XXXXXXXX)/fifo
|
output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-grep.XXXXXXXX)/fifo
|
||||||
|
|
Loading…
Reference in New Issue
Block a user