1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-29 01:24:52 +03:00

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.
This commit is contained in:
Maxime Coste 2016-01-10 20:41:46 +00:00
parent 3dee04b701
commit 99c5b7e678
7 changed files with 14 additions and 14 deletions

View File

@ -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}")

View File

@ -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

View File

@ -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 '

View File

@ -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
}

View File

@ -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\);;

View File

@ -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"

View File

@ -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