From 09f067d58552094d53c8a68a151cf8f08fad75dd Mon Sep 17 00:00:00 2001 From: Tim Allen Date: Sun, 9 Feb 2020 14:01:35 +1100 Subject: [PATCH] rc lint: More code-review comments. Don't ask Kakoune to quote values we know can never contain shell-sensitive characters, and flatten the kakquote() function to a single line for ease of copy/pasting. --- rc/tools/lint.kak | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/rc/tools/lint.kak b/rc/tools/lint.kak index ba6ea012..c23e41dd 100644 --- a/rc/tools/lint.kak +++ b/rc/tools/lint.kak @@ -37,11 +37,7 @@ define-command \ # Create a temporary directory to keep all our state. evaluate-commands %sh{ # This is going to come in handy later. - kakquote() { - printf "'" - printf "%s" "$*" | sed "s/'/''/g" - printf "'" - } + kakquote() { printf "%s" "$*" | sed "s/'/''/g; 1s/^/'/; \$s/\$/'/"; } # Before we clobber our arguments, # let's record the lintcmd we were given. @@ -65,7 +61,7 @@ define-command \ }" # Write all the selection descriptions to files. - eval set -- "$kak_quoted_selections_desc" + eval set -- "$kak_selections_desc" i=0 for desc; do mkdir -p "$dir"/sel-"$i" @@ -260,11 +256,7 @@ define-command \ evaluate-commands %sh{ # This is going to come in handy later. - kakquote() { - printf "'" - printf "%s" "$*" | sed "s/'/''/g" - printf "'" - } + kakquote() { printf "%s" "$*" | sed "s/'/''/g; 1s/^/'/; \$s/\$/'/"; } if [ "$1" = "-command" ]; then if [ -z "$2" ]; then @@ -307,11 +299,7 @@ define-command -hidden lint-show %{ update-option buffer lint_messages evaluate-commands %sh{ # This is going to come in handy later. - kakquote() { - printf "'" - printf "%s" "$*" | sed "s/'/''/g" - printf "'" - } + kakquote() { printf "%s" "$*" | sed "s/'/''/g; 1s/^/'/; \$s/\$/'/"; } eval set -- "${kak_quoted_opt_lint_messages}" shift # skip the timestamp