summaryrefslogtreecommitdiffstats
path: root/completions/portinstall
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:03:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:03:19 +0000
commit6c09f2a45c5541e9c207d14fc7aa21a4a0066bde (patch)
tree0221189d367bf661f6f9493c4f17a03f0dd4b7d2 /completions/portinstall
parentReleasing progress-linux version 1:2.11-8~progress7.99u1. (diff)
downloadbash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.tar.xz
bash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.zip
Merging upstream version 1:2.12.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'completions/portinstall')
-rw-r--r--completions/portinstall29
1 files changed, 13 insertions, 16 deletions
diff --git a/completions/portinstall b/completions/portinstall
index 8033740..dc1a933 100644
--- a/completions/portinstall
+++ b/completions/portinstall
@@ -1,31 +1,28 @@
# bash completion for FreeBSD portinstall -*- shell-script -*-
-_portinstall()
+_comp_cmd_portinstall()
{
- local cur prev words cword
- _init_completion || return
+ 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 -- "$(_comp_awk -F '|' '
+ BEGIN { portsdir = ENVIRON["portsdir"]; len = length(portsdir) }
+ { print $1 }
+ substr($2, 1, len) == portsdir { print substr($2, len + 1) }
+ ' "$indexfile")"
} &&
- complete -F _portinstall -o dirnames portinstall
+ complete -F _comp_cmd_portinstall -o dirnames portinstall
# ex: filetype=sh