Skip to content

Commit

Permalink
fix(kldload,mplayer,mutt): work around nounset
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga authored and scop committed Jan 3, 2024
1 parent 3183e67 commit 5330fbe
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 30 deletions.
16 changes: 9 additions & 7 deletions completions/kldload
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ _comp_cmd_kldload()
moddirs=($(kldconfig -r 2>/dev/null))
_comp_unlocal IFS

compopt -o filenames
for i in "${moddirs[@]}"; do
_comp_compgen -v modules -c "$i/$cur" -- -f &&
COMPREPLY+=("${modules[@]#$i/}")
done
((${#COMPREPLY[@]})) &&
COMPREPLY=("${COMPREPLY[@]%.ko}")
if ((${#moddirs[@]})); then
compopt -o filenames
for i in "${moddirs[@]}"; do
_comp_compgen -v modules -c "$i/$cur" -- -f &&
COMPREPLY+=("${modules[@]#$i/}")
done
((${#COMPREPLY[@]})) &&
COMPREPLY=("${COMPREPLY[@]%.ko}")
fi

# also add dirs in current dir
_comp_compgen -a filedir -d
Expand Down
39 changes: 21 additions & 18 deletions completions/mplayer
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,16 @@ _comp_cmd_mplayer()
return
;;
-vobsub)
_comp_compgen_filedir '@(idx|ifo|sub)'
local IFS=$'\n'
COMPREPLY=($(for i in "${COMPREPLY[@]}"; do
if [[ -f $i && -r $i ]]; then
printf '%s\n' "${i%.*}"
else
printf '%s\n' "$i"
fi
done))
if _comp_compgen_filedir '@(idx|ifo|sub)'; then
local IFS=$'\n'
COMPREPLY=($(for i in "${COMPREPLY[@]}"; do
if [[ -f $i && -r $i ]]; then
printf '%s\n' "${i%.*}"
else
printf '%s\n' "$i"
fi
done))
fi
return
;;
-subcp | -msgcharset)
Expand Down Expand Up @@ -84,15 +85,17 @@ _comp_cmd_mplayer()
dirs=(/usr/share/mplayer/skins /usr/local/share/mplayer/skins)
fi

local -a subdirs
for i in ~/.mplayer/skins "${dirs[@]}"; do
if [[ -d $i && -r $i ]]; then
_comp_compgen -v subdirs -c "$i/$cur" -- -d
for j in "${subdirs[@]}"; do
COMPREPLY[k++]=${j#"$i/"}
done
fi
done
if ((${#dirs[@]})); then
local -a subdirs
for i in ~/.mplayer/skins "${dirs[@]}"; do
if [[ -d $i && -r $i ]]; then
_comp_compgen -v subdirs -c "$i/$cur" -- -d
for j in "${subdirs[@]}"; do
COMPREPLY[k++]=${j#"$i/"}
done
fi
done
fi
return
;;
-cdrom-device)
Expand Down
8 changes: 3 additions & 5 deletions completions/mutt
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,16 @@ _comp_cmd_mutt__query()
local -a queryresults

querycmd="$("$muttcmd" -Q query_command 2>/dev/null | command sed -e 's|^query_command=\"\(.*\)\"$|\1|' -e 's|%s|'"$cur"'|')"
if [[ ! $cur || ! $querycmd ]]; then
queryresults=()
else
if [[ $cur && $querycmd ]]; then
local REPLY
_comp_expand_tilde "$querycmd"
querycmd=$REPLY
# $querycmd is expected to be a command with arguments
queryresults=($($querycmd |
command sed -n '2,$s|^\([^[:space:]]\{1,\}\).*|\1|p'))
((${#queryresults[@]})) &&
_comp_compgen -a -- -W '"${queryresults[@]}"'
fi

_comp_compgen -a -- -W '"${queryresults[@]}"'
}

# @param $1 (cur) Current word to complete
Expand Down

0 comments on commit 5330fbe

Please sign in to comment.