summaryrefslogtreecommitdiffstats
path: root/completions/portinstall
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:03:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:03:18 +0000
commitf4acb49ea148cdd899f7f29f1591c7bc853c2135 (patch)
treeb62d60873864065d6428a84a119dd8a3c90f1397 /completions/portinstall
parentAdding upstream version 1:2.11. (diff)
downloadbash-completion-f4acb49ea148cdd899f7f29f1591c7bc853c2135.tar.xz
bash-completion-f4acb49ea148cdd899f7f29f1591c7bc853c2135.zip
Adding upstream version 1:2.12.0.upstream/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