[bash] Fix shellcheck warnings
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Close #516
authored by Junegunn Choi · committed by Junegunn Choi · parent 6cf5483 · Browse files · 2 files·+23 added−23 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+23 added−23 removed
- other:+23 added−23 removed
Provenance
- Commit
09a2ab3- Tree
5f6ff72- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
6cf5483
2 files changed+23 added−23 removed
modified:shell/completion.bash+18 added-18 removed
73 unmodified lines74 --margin"75 76 case "${prev}" in77 --tiebreak)78- COMPREPLY=( $(compgen -W "length begin end index" -- ${cur}) )78+ COMPREPLY=( $(compgen -W "length begin end index" -- "$cur") )79 return 080 ;;81 --color)82- COMPREPLY=( $(compgen -W "dark light 16 bw" -- ${cur}) )82+ COMPREPLY=( $(compgen -W "dark light 16 bw" -- "$cur") )83 return 084 ;;85 --history)86 COMPREPLY=()87 return 088 ;;89 esac90 91- if [[ ${cur} =~ ^-|\+ ]]; then92- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )91+ if [[ "$cur" =~ ^-|\+ ]]; then92+ COMPREPLY=( $(compgen -W "${opts}" -- "$cur") )93 return 094 fi95 96 return 010 unmodified lines107 $orig "$@"108 elif [ -n "$_fzf_completion_loader" ]; then109 _completion_loader "$@"110 ret=$?111- eval $(complete | \grep "\-F.* $orig_cmd$" | _fzf_orig_completion_filter)112- source $BASH_SOURCE111+ eval "$(complete | \grep "\-F.* $orig_cmd$" | _fzf_orig_completion_filter)"112+ source "${BASH_SOURCE[0]}"113 return $ret114 fi115 }116 117 __fzf_generic_path_completion() {118 local cur base dir leftover matches trigger cmd fzf119- [ ${FZF_TMUX:-1} -eq 1 ] && fzf="fzf-tmux -d ${FZF_TMUX_HEIGHT:-40%}" || fzf="fzf"120- cmd=$(echo ${COMP_WORDS[0]} | sed 's/[^a-z0-9_=]/_/g')119+ [ "${FZF_TMUX:-1}" != 0 ] && fzf="fzf-tmux -d ${FZF_TMUX_HEIGHT:-40%}" || fzf="fzf"120+ cmd=$(echo "${COMP_WORDS[0]}" | sed 's/[^a-z0-9_=]/_/g')121 COMPREPLY=()122 trigger=${FZF_COMPLETION_TRIGGER-'**'}123 cur="${COMP_WORDS[COMP_CWORD]}"124- if [[ ${cur} == *"$trigger" ]]; then124+ if [[ "$cur" == *"$trigger" ]]; then125 base=${cur:0:${#cur}-${#trigger}}126- eval base=$base126+ eval "base=$base"127 128 dir="$base"129- while [ 1 ]; do130- if [ -z "$dir" -o -d "$dir" ]; then129+ while true; do130+ if [ -z "$dir" ] || [ -d "$dir" ]; then131 leftover=${base/#"$dir"}132 leftover=${leftover/#\/}133 [ -z "$dir" ] && dir='.'134 [ "$dir" != "/" ] && dir="${dir/%\//}"135 tput sc136- matches=$(eval "$1 $(printf %q "$dir")" | $fzf $FZF_COMPLETION_OPTS $2 -q "$leftover" | while read item; do136+ matches=$(eval "$1 $(printf %q "$dir")" | $fzf $FZF_COMPLETION_OPTS $2 -q "$leftover" | while read -r item; do137 printf "%q$3 " "$item"138 done)139 matches=${matches% }140 if [ -n "$matches" ]; then17 unmodified lines158 159 _fzf_complete() {160 local cur selected trigger cmd fzf post161 post="$(caller 0 | awk '{print $2}')_post"162- type -t $post > /dev/null 2>&1 || post=cat163- [ ${FZF_TMUX:-1} -eq 1 ] && fzf="fzf-tmux -d ${FZF_TMUX_HEIGHT:-40%}" || fzf="fzf"162+ type -t "$post" > /dev/null 2>&1 || post=cat163+ [ "${FZF_TMUX:-1}" != 0 ] && fzf="fzf-tmux -d ${FZF_TMUX_HEIGHT:-40%}" || fzf="fzf"164 165- cmd=$(echo ${COMP_WORDS[0]} | sed 's/[^a-z0-9_=]/_/g')165+ cmd=$(echo "${COMP_WORDS[0]}" | sed 's/[^a-z0-9_=]/_/g')166 trigger=${FZF_COMPLETION_TRIGGER-'**'}167 cur="${COMP_WORDS[COMP_CWORD]}"168- if [[ ${cur} == *"$trigger" ]]; then168+ if [[ "$cur" == *"$trigger" ]]; then169 cur=${cur:0:${#cur}-${#trigger}}170 171 tput sc172 selected=$(cat | $fzf $FZF_COMPLETION_OPTS $1 -q "$cur" | $post | tr '\n' ' ')26 unmodified lines199 _fzf_complete_kill() {200 [ -n "${COMP_WORDS[COMP_CWORD]}" ] && return 1201 202 local selected fzf203- [ ${FZF_TMUX:-1} -eq 1 ] && fzf="fzf-tmux -d ${FZF_TMUX_HEIGHT:-40%}" || fzf="fzf"203+ [ "${FZF_TMUX:-1}" != 0 ] && fzf="fzf-tmux -d ${FZF_TMUX_HEIGHT:-40%}" || fzf="fzf"204 tput sc205 selected=$(ps -ef | sed 1d | $fzf -m $FZF_COMPLETION_OPTS | awk '{print $2}' | tr '\n' ' ')206 tput rc207 105 unmodified linesmodified:shell/key-bindings.bash+5 added-5 removed
3 unmodified lines4567889101112131415161717181920217 unmodified lines293031323333343536363738394019 unmodified lines6061626364646566676846 unmodified lines3 unmodified lines local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . \\( -path '*/\\.*' -o -fstype 'dev' -o -fstype 'proc' \\) -prune \ -o -type f -print \ -o -type d -print \ -o -type l -print 2> /dev/null | sed 1d | cut -b3-"}" eval "$cmd" | fzf -m | while read item; do eval "$cmd" | fzf -m | while read -r item; do printf '%q ' "$item" done echo}
if [[ $- =~ i ]]; then
__fzfcmd() { [ ${FZF_TMUX:-1} -eq 1 ] && echo "fzf-tmux -d${FZF_TMUX_HEIGHT:-40%}" || echo "fzf" [ "${FZF_TMUX:-1}" != 0 ] && echo "fzf-tmux -d${FZF_TMUX_HEIGHT:-40%}" || echo "fzf"}
__fzf_select_tmux__() { local height7 unmodified lines tmux split-window $height "cd $(printf %q "$PWD"); FZF_DEFAULT_OPTS=$(printf %q "$FZF_DEFAULT_OPTS") PATH=$(printf %q "$PATH") FZF_CTRL_T_COMMAND=$(printf %q "$FZF_CTRL_T_COMMAND") bash -c 'source \"${BASH_SOURCE[0]}\"; tmux send-keys -t $TMUX_PANE \"\$(__fzf_select__)\"'"}
__fzf_select_tmux_auto__() { if [ ${FZF_TMUX:-1} -ne 0 -a ${LINES:-40} -gt 15 ]; then if [ "${FZF_TMUX:-1}" != 0 ] && [ ${LINES:-40} -gt 15 ]; then __fzf_select_tmux__ else tmux send-keys -t $TMUX_PANE "$(__fzf_select__)" tmux send-keys -t "$TMUX_PANE" "$(__fzf_select__)" fi}
__fzf_cd__() {19 unmodified lines
__use_tmux=0__use_tmux_auto=0if [ -n "$TMUX_PANE" ]; then [ ${FZF_TMUX:-1} -ne 0 -a ${LINES:-40} -gt 15 ] && __use_tmux=1 [ "${FZF_TMUX:-1}" != 0 ] && [ ${LINES:-40} -gt 15 ] && __use_tmux=1 [ $BASH_VERSINFO -gt 3 ] && __use_tmux_auto=1fi
if [ -z "$(set -o | \grep '^vi.*on')" ]; then46 unmodified lines