From f2159750d28153b68b244d2bdcc3905e0efa425d Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 31 Dec 2019 12:50:19 +1100 Subject: [PATCH] Slight code cleanup in grep.kak --- rc/tools/grep.kak | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rc/tools/grep.kak b/rc/tools/grep.kak index 25062f38..7233d02e 100644 --- a/rc/tools/grep.kak +++ b/rc/tools/grep.kak @@ -8,13 +8,13 @@ define-command -params .. -file-completion \ -docstring %{grep []: 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 + ( ${kak_opt_grepcmd} "$@" | tr -d '\r' > ${output} 2>&1 & ) > /dev/null 2>&1 < /dev/null printf %s\\n "evaluate-commands -try-client '$kak_opt_toolsclient' %{ edit! -fifo ${output} *grep*