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:
parent
3dee04b701
commit
99c5b7e678
|
@ -162,7 +162,7 @@ hook global BufNew .*\.(h|hh|hpp|hxx|H) _c-family-insert-include-guards
|
||||||
decl str-list alt_dirs ".;.."
|
decl str-list alt_dirs ".;.."
|
||||||
|
|
||||||
def c-family-alternative-file -docstring "Jump to the alternate file (header/implementation)" %{ %sh{
|
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}")
|
file=$(basename "${kak_buffile}")
|
||||||
dir=$(dirname "${kak_buffile}")
|
dir=$(dirname "${kak_buffile}")
|
||||||
|
|
||||||
|
|
|
@ -118,14 +118,14 @@ def clang-enable-autocomplete -docstring "Enable completion with clang" %{
|
||||||
}
|
}
|
||||||
|
|
||||||
def clang-disable-autocomplete -docstring "Disable automatic clang completion" %{
|
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
|
rmhooks window clang-autocomplete
|
||||||
unalias window complete clang-complete
|
unalias window complete clang-complete
|
||||||
}
|
}
|
||||||
|
|
||||||
def -allow-override -hidden clang-show-error-info %{ %sh{
|
def -allow-override -hidden clang-show-error-info %{ %sh{
|
||||||
echo "${kak_opt_clang_errors}" | grep "^${kak_cursor_line},.*" | if read line; then
|
printf %s "${kak_opt_clang_errors}" | grep "^${kak_cursor_line},.*" | if read line; then
|
||||||
desc=$(echo ${line} | sed -e "s/^[[:digit:]]\+,//g; s/'/\\\\'/g")
|
desc=$(printf %s ${line} | sed -e "s/^[[:digit:]]\+,//g; s/'/\\\\'/g")
|
||||||
echo "info -anchor ${kak_cursor_line}.${kak_cursor_column} '${desc}'"
|
echo "info -anchor ${kak_cursor_line}.${kak_cursor_column} '${desc}'"
|
||||||
fi
|
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{
|
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
|
line=-1
|
||||||
first_line=-1
|
first_line=-1
|
||||||
while read line_content; do
|
while read line_content; do
|
||||||
|
|
|
@ -7,7 +7,7 @@ decl str-list ctagsfiles 'tags'
|
||||||
|
|
||||||
def -params 0..1 \
|
def -params 0..1 \
|
||||||
-shell-completion '
|
-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"
|
do readtags -t "${tags}" -p "$1"
|
||||||
done ) | cut -f 1 | sort | uniq' \
|
done ) | cut -f 1 | sort | uniq' \
|
||||||
-docstring 'Jump to tag definition' \
|
-docstring 'Jump to tag definition' \
|
||||||
|
@ -15,7 +15,7 @@ def -params 0..1 \
|
||||||
%{ %sh{
|
%{ %sh{
|
||||||
export tagname=${1:-${kak_selection}}
|
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}
|
readtags -t "${tags}" ${tagname}
|
||||||
done
|
done
|
||||||
) | awk -F '\t|\n' -e '
|
) | awk -F '\t|\n' -e '
|
||||||
|
|
|
@ -38,7 +38,7 @@ def jedi-enable-autocomplete -docstring "Add jedi completion candidates to the c
|
||||||
}
|
}
|
||||||
|
|
||||||
def jedi-disable-autocomplete -docstring "Disable jedi completion" %{
|
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
|
rmhooks window jedi-autocomplete
|
||||||
unalias window complete jedi-complete
|
unalias window complete jedi-complete
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ def -params .. \
|
||||||
prefix=${1:0:${kak_pos_in_token}}
|
prefix=${1:0:${kak_pos_in_token}}
|
||||||
for page in /usr/share/man/*/${prefix}*.[1-8]*; do
|
for page in /usr/share/man/*/${prefix}*.[1-8]*; do
|
||||||
candidate=$(basename ${page%%.[1-8]*})
|
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
|
case $candidate in
|
||||||
*\*) ;;
|
*\*) ;;
|
||||||
*) echo $candidate\($pagenum\);;
|
*) echo $candidate\($pagenum\);;
|
||||||
|
|
|
@ -16,15 +16,15 @@ def spell %{
|
||||||
while read line; do
|
while read line; do
|
||||||
case $line in
|
case $line in
|
||||||
\&*)
|
\&*)
|
||||||
word=$(echo "$line" | cut -d ' ' -f 2)
|
word=$(printf %s "$line" | cut -d ' ' -f 2)
|
||||||
begin=$(echo "$line" | cut -d ' ' -f 4 | sed 's/:$//')
|
begin=$(printf %s "$line" | cut -d ' ' -f 4 | sed 's/:$//')
|
||||||
end=$((begin + ${#word}))
|
end=$((begin + ${#word}))
|
||||||
# echo "echo -debug -- line: $line_num, word: $word, begin: $begin, end: $end"
|
# echo "echo -debug -- line: $line_num, word: $word, begin: $begin, end: $end"
|
||||||
regions="$regions:$line_num.$begin,$line_num.$end|Error"
|
regions="$regions:$line_num.$begin,$line_num.$end|Error"
|
||||||
;;
|
;;
|
||||||
'#'*)
|
'#'*)
|
||||||
word=$(echo "$line" | cut -d ' ' -f 2)
|
word=$(printf %s "$line" | cut -d ' ' -f 2)
|
||||||
begin=$(echo "$line" | cut -d ' ' -f 3)
|
begin=$(printf %s "$line" | cut -d ' ' -f 3)
|
||||||
end=$((begin + ${#word}))
|
end=$((begin + ${#word}))
|
||||||
# echo "echo -debug -- line: $line_num, word: $word, begin: $begin, end: $end"
|
# echo "echo -debug -- line: $line_num, word: $word, begin: $begin, end: $end"
|
||||||
regions="$regions:$line_num.$begin,$line_num.$end|Error"
|
regions="$regions:$line_num.$begin,$line_num.$end|Error"
|
||||||
|
|
|
@ -12,7 +12,7 @@ decl str termcmd %sh{
|
||||||
'xfce4-terminal -e ' ; do
|
'xfce4-terminal -e ' ; do
|
||||||
terminal=${termcmd%% *}
|
terminal=${termcmd%% *}
|
||||||
if which $terminal > /dev/null 2>&1; then
|
if which $terminal > /dev/null 2>&1; then
|
||||||
echo "'$termcmd'"
|
printf %s "'$termcmd'"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue
Block a user