Skip to content

Commit

Permalink
Merge pull request #1053 from akinomyoga/misc-2
Browse files Browse the repository at this point in the history
fix: add misc fixes (misc-2)
  • Loading branch information
scop committed Oct 4, 2023
2 parents b6d06bc + 791f56c commit 15b74b1
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 31 deletions.
4 changes: 2 additions & 2 deletions completions/_mock
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ _comp_cmd_mock()
return
;;
-r | --root)
_comp_compgen_split -- "$(command ls "$cfgdir")"
COMPREPLY=(${COMPREPLY[@]/%.cfg/})
_comp_compgen_split -- "$(command ls "$cfgdir")" &&
COMPREPLY=(${COMPREPLY[@]/%.cfg/})
return
;;
--configdir | --resultdir)
Expand Down
6 changes: 4 additions & 2 deletions completions/_mount.linux
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ _comp_cmd_mount()
qnx4 ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs udf
ufs umsdos usbfs vfat xfs'
_comp_compgen -a fstypes
[[ $split ]] && COMPREPLY=(${COMPREPLY[@]/#/$prev,})
[[ $split ]] && ((${#COMPREPLY[@]})) &&
COMPREPLY=(${COMPREPLY[@]/#/$prev,})
return
;;
--bind | -B | --rbind | -R)
Expand Down Expand Up @@ -202,7 +203,8 @@ _comp_cmd_mount()
esac
# COMP_WORDBREAKS is a real pain in the ass
prev="${prev##*["$COMP_WORDBREAKS"]}"
[[ $split ]] && COMPREPLY=(${COMPREPLY[@]/#/"$prev,"})
[[ $split ]] && ((${COMPREPLY[@]})) &&
COMPREPLY=(${COMPREPLY[@]/#/"$prev,"})
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
;;
Expand Down
3 changes: 2 additions & 1 deletion completions/_umount.linux
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ _comp_cmd_umount()
reiserfs romfs squashfs smbfs sysv tmpfs ubifs udf ufs umsdos
usbfs vfat xfs'
_comp_compgen -a fstypes
[[ $split ]] && COMPREPLY=(${COMPREPLY[@]/#/$prev,})
[[ $split ]] && ((${#COMPREPLY[@]})) &&
COMPREPLY=(${COMPREPLY[@]/#/$prev,})
return
;;
-O)
Expand Down
2 changes: 1 addition & 1 deletion completions/aptitude
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ _comp_cmd_aptitude()
--target-release | --default-release | -${noargopts}t)
COMPREPLY=($(apt-cache policy |
command grep "release.o=Debian,a=$cur" |
command sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2>/dev/null))
command sed -e "s/.*a=\([_[:alnum:]]*\).*/\1/" | uniq 2>/dev/null))
return
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion completions/isql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ _comp_cmd_isql()
local cur prev words cword comp_args
_comp_initialize -- "$@" || return

[[ -f $ODBCINI ]] &&
[[ -f ${ODBCINI-} ]] &&
COMPREPLY=($(command grep "\[$cur" "$ODBCINI" | tr -d \[\]))
} &&
complete -F _comp_cmd_isql isql
Expand Down
4 changes: 2 additions & 2 deletions completions/kldunload
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ _comp_cmd_kldunload()
local cur prev words cword comp_args
_comp_initialize -- "$@" || return

_comp_compgen_split -X '!*.ko' -- "$(kldstat)"
COMPREPLY=(${COMPREPLY[@]%.ko})
_comp_compgen_split -X '!*.ko' -- "$(kldstat)" &&
COMPREPLY=(${COMPREPLY[@]%.ko})
} &&
complete -F _comp_cmd_kldunload kldunload

Expand Down
21 changes: 9 additions & 12 deletions completions/portinstall
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,22 @@ _comp_cmd_portinstall()
local cur prev words cword comp_args
_comp_initialize -- "$@" || return

local portsdir indexfile
local -a COMPREPLY2
[[ $prev == -l || $prev == -L || $prev == -o ]] && return

portsdir=${PORTSDIR:-/usr/ports}/
local -x portsdir=${PORTSDIR:-/usr/ports}/

# First try INDEX-5
indexfile=$portsdir/INDEX-5
local indexfile=$portsdir/INDEX-5
# Then INDEX if INDEX-5 does not exist or system is not FreeBSD 5.x
[[ ${OSTYPE%.*} == freebsd5 && -f $indexfile ]] ||
indexfile=$portsdir/INDEX
[[ -f $indexfile && -r $indexfile ]] || return

[[ $prev == -l || $prev == -L || $prev == -o ]] && return

COMPREPLY=($(command grep -E "^$cur" 2>/dev/null <"$indexfile" |
cut -d'|' -f1))
COMPREPLY2=($(command grep -E "^[^\|]+\|$portsdir$cur" 2>/dev/null \
<"$indexfile" | cut -d'|' -f2))
COMPREPLY2=(${COMPREPLY2[@]#$portsdir})
COMPREPLY+=("${COMPREPLY2[@]}")
_comp_compgen_split -l -- "$(awk -F '|' '
BEGIN { portsdir = ENVIRON["portsdir"]; len = length(portsdir) }
{ print $1 }
substr($2, 1, len) == portsdir { print substr($2, len + 1) }
' "$indexfile")"

} &&
complete -F _comp_cmd_portinstall -o dirnames portinstall
Expand Down
8 changes: 3 additions & 5 deletions completions/povray
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ _comp_cmd_povray()
*.ini\[ | *.ini\[*[^]]) # sections in .ini files
cur="${povcur#*\[}"
pfx="${povcur%\["$cur"}" # prefix == filename
[[ -r $pfx ]] || return
COMPREPLY=($(
command sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' \
-e 't' -e 'd' -- "$pfx"
))
[[ -f $pfx && -r $pfx ]] || return
COMPREPLY=($(command sed -ne \
's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/p' -- "$pfx"))
# to prevent [bar] expand to nothing. can be done more easily?
((${#COMPREPLY[@]})) && COMPREPLY=("${COMPREPLY[@]/#/${pfx}[}")
return
Expand Down
4 changes: 2 additions & 2 deletions completions/psql
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ _comp_cmd_psql__users()
{
# -w was introduced in 8.4, https://launchpad.net/bugs/164772
_comp_compgen_split -- "$(psql -XAtqwc 'select usename from pg_user' \
template1 2>/dev/null)"
((${#COMPREPLY[@]} == 0)) && _comp_compgen -- -u
template1 2>/dev/null)" ||
_comp_compgen -- -u
}

# createdb(1) completion
Expand Down
6 changes: 3 additions & 3 deletions completions/sbopkg
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ _comp_cmd_sbopkg()
fi
done

[[ -r $config ]] || return
[[ -f $config && -r $config ]] || return
. "$config"

for ((i = 1; i < ${#words[@]} - 1; i++)); do
Expand All @@ -59,10 +59,10 @@ _comp_cmd_sbopkg()
esac
done
local file=${REPO_ROOT-}/${REPO_NAME-}/${REPO_BRANCH-}/SLACKBUILDS.TXT
[[ -r $file ]] || return
[[ -f $file && -r $file ]] || return

COMPREPLY=($(
command sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p}" \
command sed -ne "/^SLACKBUILD NAME: $cur/{s/^SLACKBUILD NAME: //;p;}" \
"$file"
))
_comp_compgen -aC "$QUEUEDIR" -- -f -X "!*.sqf"
Expand Down

0 comments on commit 15b74b1

Please sign in to comment.