summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2016-01-10 20:41:46 +0000
committerMaxime Coste <frrrwww@gmail.com>2016-01-10 20:41:46 +0000
commit99c5b7e678c7aa061f27979ace237a2154dd67ac (patch)
treebab127ae63ed4ffd2f2ffeadb224522e83e53a95
parent3dee04b70184797234d5bb2d1a48b28e4f906fc7 (diff)
Replace potentially problematic uses of echo with printf %s
Echo supported switches are not well defined, so echo usage that directly pass a shell variable as parameter may not have the expected behaviour. Using printf %s should be safer.
-rw-r--r--rc/c-family.kak2
-rw-r--r--rc/clang.kak8
-rw-r--r--rc/ctags.kak4
-rw-r--r--rc/jedi.kak2
-rw-r--r--rc/man.kak2
-rw-r--r--rc/spell.kak8
-rw-r--r--rc/x11.kak2
7 files changed, 14 insertions, 14 deletions
diff --git a/rc/c-family.kak b/rc/c-family.kak
index c3ec29d5..1ddea865 100644
--- a/rc/c-family.kak
+++ b/rc/c-family.kak
@@ -162,7 +162,7 @@ hook global BufNew .*\.(h|hh|hpp|hxx|H) _c-family-insert-include-guards
decl str-list alt_dirs ".;.."
def c-family-alternative-file -docstring "Jump to the alternate file (header/implementation)" %{ %sh{
- alt_dirs=$(echo ${kak_opt_alt_dirs} | sed -e 's/;/ /g')
+ alt_dirs=$(printf %s "${kak_opt_alt_dirs}" | sed -e 's/;/ /g')
file=$(basename "${kak_buffile}")
dir=$(dirname "${kak_buffile}")
diff --git a/rc/clang.kak b/rc/clang.kak
index b7db9479..343f16ca 100644
--- a/rc/clang.kak
+++ b/rc/clang.kak
@@ -118,14 +118,14 @@ def clang-enable-autocomplete -docstring "Enable completion with clang" %{
}
def clang-disable-autocomplete -docstring "Disable automatic clang completion" %{
- set window completers %sh{ echo "'${kak_opt_completers}'" | sed -e 's/option=clang_completions://g' }
+ set window completers %sh{ printf %s "'${kak_opt_completers}'" | sed -e 's/option=clang_completions://g' }
rmhooks window clang-autocomplete
unalias window complete clang-complete
}
def -allow-override -hidden clang-show-error-info %{ %sh{
- echo "${kak_opt_clang_errors}" | grep "^${kak_cursor_line},.*" | if read line; then
- desc=$(echo ${line} | sed -e "s/^[[:digit:]]\+,//g; s/'/\\\\'/g")
+ printf %s "${kak_opt_clang_errors}" | grep "^${kak_cursor_line},.*" | if read line; then
+ desc=$(printf %s ${line} | sed -e "s/^[[:digit:]]\+,//g; s/'/\\\\'/g")
echo "info -anchor ${kak_cursor_line}.${kak_cursor_column} '${desc}'"
fi
} }
@@ -141,7 +141,7 @@ def clang-disable-diagnostics -docstring "Disable automatic diagnostics of the c
}
def clang-diagnostics-next -docstring "Jump to the next line that contains an error" %{ %sh{
- echo "${kak_opt_clang_errors}" | (
+ printf %s "${kak_opt_clang_errors}" | (
line=-1
first_line=-1
while read line_content; do
diff --git a/rc/ctags.kak b/rc/ctags.kak
index 4ec6affc..ca31cbab 100644
--- a/rc/ctags.kak
+++ b/rc/ctags.kak
@@ -7,7 +7,7 @@ decl str-list ctagsfiles 'tags'
def -params 0..1 \
-shell-completion '
- ( for tags in $(echo "${kak_opt_ctagsfiles}" | tr \':\' \'\n\');
+ ( for tags in $(printf %s "${kak_opt_ctagsfiles}" | tr \':\' \'\n\');
do readtags -t "${tags}" -p "$1"
done ) | cut -f 1 | sort | uniq' \
-docstring 'Jump to tag definition' \
@@ -15,7 +15,7 @@ def -params 0..1 \
%{ %sh{
export tagname=${1:-${kak_selection}}
(
- for tags in $(echo "${kak_opt_ctagsfiles}" | tr ':' '\n'); do
+ for tags in $(printf %s "${kak_opt_ctagsfiles}" | tr ':' '\n'); do
readtags -t "${tags}" ${tagname}
done
) | awk -F '\t|\n' -e '
diff --git a/rc/jedi.kak b/rc/jedi.kak
index c588968e..801740cb 100644
--- a/rc/jedi.kak
+++ b/rc/jedi.kak
@@ -38,7 +38,7 @@ def jedi-enable-autocomplete -docstring "Add jedi completion candidates to the c
}
def jedi-disable-autocomplete -docstring "Disable jedi completion" %{
- set window completers %sh{ echo "'${kak_opt_completers}'" | sed -e 's/option=jedi_completions://g' }
+ set window completers %sh{ printf %s "'${kak_opt_completers}'" | sed -e 's/option=jedi_completions://g' }
rmhooks window jedi-autocomplete
unalias window complete jedi-complete
}
diff --git a/rc/man.kak b/rc/man.kak
index bff92625..c1ef62e8 100644
--- a/rc/man.kak
+++ b/rc/man.kak
@@ -37,7 +37,7 @@ def -params .. \
prefix=${1:0:${kak_pos_in_token}}
for page in /usr/share/man/*/${prefix}*.[1-8]*; do
candidate=$(basename ${page%%.[1-8]*})
- pagenum=$(echo $page | sed -r 's,^.+/.+\.([1-8][^.]*)\..+$,\1,')
+ pagenum=$(printf %s "$page" | sed -r 's,^.+/.+\.([1-8][^.]*)\..+$,\1,')
case $candidate in
*\*) ;;
*) echo $candidate\($pagenum\);;
diff --git a/rc/spell.kak b/rc/spell.kak
index 5d750a88..80043cfc 100644
--- a/rc/spell.kak
+++ b/rc/spell.kak
@@ -16,15 +16,15 @@ def spell %{
while read line; do
case $line in
\&*)
- word=$(echo "$line" | cut -d ' ' -f 2)
- begin=$(echo "$line" | cut -d ' ' -f 4 | sed 's/:$//')
+ word=$(printf %s "$line" | cut -d ' ' -f 2)
+ begin=$(printf %s "$line" | cut -d ' ' -f 4 | sed 's/:$//')
end=$((begin + ${#word}))
# echo "echo -debug -- line: $line_num, word: $word, begin: $begin, end: $end"
regions="$regions:$line_num.$begin,$line_num.$end|Error"
;;
'#'*)
- word=$(echo "$line" | cut -d ' ' -f 2)
- begin=$(echo "$line" | cut -d ' ' -f 3)
+ word=$(printf %s "$line" | cut -d ' ' -f 2)
+ begin=$(printf %s "$line" | cut -d ' ' -f 3)
end=$((begin + ${#word}))
# echo "echo -debug -- line: $line_num, word: $word, begin: $begin, end: $end"
regions="$regions:$line_num.$begin,$line_num.$end|Error"
diff --git a/rc/x11.kak b/rc/x11.kak
index dc4595e4..f485a416 100644
--- a/rc/x11.kak
+++ b/rc/x11.kak
@@ -12,7 +12,7 @@ decl str termcmd %sh{
'xfce4-terminal -e ' ; do
terminal=${termcmd%% *}
if which $terminal > /dev/null 2>&1; then
- echo "'$termcmd'"
+ printf %s "'$termcmd'"
exit
fi
done