From d09dd09b6c61ec0af0eb44273ecaad9c5b59983a Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 3 Dec 2015 13:38:37 +0000 Subject: [PATCH] commenting.kak: fix bashism and cleanup --- rc/commenting.kak | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/rc/commenting.kak b/rc/commenting.kak index f11e5634..6f72db62 100644 --- a/rc/commenting.kak +++ b/rc/commenting.kak @@ -8,7 +8,7 @@ def comment-selection -docstring "Comment/uncomment the current selection" %{ %sh{ function exec_proof { ## Replace the '<' sign that is interpreted differently in `exec` - sed -r 's,<,,g' <<< "$@" + echo "$@" | sed -r 's,<,,g' } readonly opening=$(exec_proof "${kak_opt_comment_selection_chars%%:*}") @@ -39,13 +39,8 @@ def comment-selection -docstring "Comment/uncomment the current selection" %{ def comment-line -docstring "Comment/uncomment the current line" %{ %sh{ - function escape_regex_chars { - ## Escape characters that can be interpreted as modifiers/repetitors by the regex engine - sed -r 's,(\*|\+|\[|\]|\{\}|\||\(|\)|\?),\\\1,g' <<< "$@" - } - readonly opening="${kak_opt_comment_line_chars}" - readonly opening_escaped=$(escape_regex_chars "${opening}") + readonly opening_escaped="\Q${opening}\E" if [ -z "${opening}" ]; then echo "The \`comment_line_chars\` variable is empty, couldn't comment the line" >&2