Slight code cleanup in grep.kak

This commit is contained in:
Maxime Coste 2019-12-31 12:50:19 +11:00
parent a17a0345cf
commit f2159750d2

View File

@ -8,13 +8,13 @@ define-command -params .. -file-completion \
-docstring %{grep [<arguments>]: grep utility wrapper
All the optional arguments are forwarded to the grep utility} \
grep %{ evaluate-commands %sh{
if [ $# -eq 0 ]; then
set -- "${kak_selection}"
fi
output=$(mktemp -d "${TMPDIR:-/tmp}"/kak-grep.XXXXXXXX)/fifo
mkfifo ${output}
if [ $# -gt 0 ]; then
( ${kak_opt_grepcmd} "$@" | tr -d '\r' > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null
else
( ${kak_opt_grepcmd} "${kak_selection}" | tr -d '\r' > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null
fi
printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{
edit! -fifo ${output} *grep*