diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:18 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:18 +0000 |
commit | f4acb49ea148cdd899f7f29f1591c7bc853c2135 (patch) | |
tree | b62d60873864065d6428a84a119dd8a3c90f1397 /completions/perl | |
parent | Adding upstream version 1:2.11. (diff) | |
download | bash-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 '')
-rw-r--r-- | completions/perl | 83 | ||||
-rw-r--r-- | completions/perlcritic | 27 | ||||
-rw-r--r-- | completions/perltidy | 46 |
3 files changed, 79 insertions, 77 deletions
diff --git a/completions/perl b/completions/perl index 9823d73..9b82777 100644 --- a/completions/perl +++ b/completions/perl @@ -1,17 +1,16 @@ # bash completion for perl -*- shell-script -*- -_perl_helper() +_comp_cmd_perl__helper() { - COMPREPLY=($(compgen -P "$prefix" -W \ - "$(${2:-perl} ${BASH_SOURCE[0]%/*}/../helpers/perl $1 $cur)" \ - -- "$cur")) - [[ $1 == functions ]] || __ltrim_colon_completions "$prefix$cur" + _comp_compgen_split -P "$prefix" -- "$("${1:-perl}" \ + "${BASH_SOURCE[0]%/*}/../helpers/perl" "$2" "$cur")" + [[ $2 == functions ]] || _comp_ltrim_colon_completions "$prefix$cur" } -_perl() +_comp_cmd_perl() { - local cur prev words cword - _init_completion -n : || return + local cur prev words cword comp_args + _comp_initialize -n : -- "$@" || return local prefix="" temp optPrefix optSuffix @@ -33,36 +32,35 @@ _perl() return ;; -*[Ix]) - local IFS=$'\n' compopt -o filenames - COMPREPLY=($(compgen -d $optPrefix $optSuffix -- "$cur")) + _comp_compgen -- -d "$optPrefix" $optSuffix return ;; -*[mM]) temp="${cur#-}" - prefix+="${cur%$temp}" + prefix+=${cur%"$temp"} cur="$temp" - _perl_helper modules $1 + _comp_cmd_perl__helper "$1" modules return ;; -*V) if [[ $cur == :* ]]; then temp="${cur##+(:)}" - prefix+="${cur%$temp}" - local IFS=$'\n' - COMPREPLY=($(compgen -P "$prefix" -W \ - '$($1 -MConfig -e "print join \"\\n\", - keys %Config::Config" 2>/dev/null)' -- "$temp")) - __ltrim_colon_completions "$prefix$temp" + prefix+=${cur%"$temp"} + _comp_compgen -c "$temp" split -lP "$prefix" -- "$( + "$1" -MConfig -e 'print join "\n", + keys %Config::Config' 2>/dev/null + )" + _comp_ltrim_colon_completions "$prefix$temp" fi return ;; -*d | -*dt) if [[ $cur == :* ]]; then temp="${cur#:}" - prefix="$prefix${cur%$temp}" + prefix=$prefix${cur%"$temp"} cur="Devel::$temp" - _perl_helper modules $1 + _comp_cmd_perl__helper "$1" modules fi ;; esac @@ -71,31 +69,31 @@ _perl() # `-E' options and their arguments, e.g. `perl -e "exit 2"', is # valid syntax. However, the argument is neither a filename nor a # directory, but one line of perl program, thus do not suggest - # _filedir completion. + # _comp_compgen_filedir completion. elif [[ $prev == -e ]] || [[ $prev == -E ]]; then return # Likewise, `-I' also accepts a space between option and argument # and it takes a directory as value. elif [[ $prev == -I ]]; then - local IFS=$'\n' compopt -o filenames - COMPREPLY=($(compgen -d ${optPrefix-} ${optSuffix-} -- "$cur")) + # shellcheck disable=SC2086 + _comp_compgen -- -d ${optPrefix-} ${optSuffix-} return elif [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p - -n -a -F -l -0 -I -m -M -P -S -x -i -e' -- "$cur")) + _comp_compgen -- -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p -n -a + -F -l -0 -I -m -M -P -S -x -i -e' else - _filedir + _comp_compgen_filedir fi } && - complete -F _perl perl + complete -F _comp_cmd_perl perl -_perldoc() +_comp_cmd_perldoc() { - local cur prev words cword - _init_completion -n : || return + local cur prev words cword comp_args + _comp_initialize -n : -- "$@" || return local prefix="" temp @@ -107,40 +105,39 @@ _perldoc() prefix=$prev fi - local perl="${1%doc}" - [[ $perl == "$1" ]] || ! type $perl &>/dev/null && perl= + # Prefer `perl` in the same dir in utility functions + local pathcmd + pathcmd=$(type -P "$1") && local PATH=${pathcmd%/*}:$PATH case $prev in -*[hVnoMwL]) return ;; -*d) - _filedir + _comp_compgen_filedir return ;; -*f) - _perl_helper functions $perl + _comp_cmd_perl__helper "" functions return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) + _comp_compgen_help -- -h else # return available modules (unless it is clearly a file) if [[ $cur != @(*/|[.~])* ]]; then - _perl_helper perldocs $perl + _comp_cmd_perl__helper "" perldocs if [[ $cur == p* ]]; then - COMPREPLY+=($(compgen -W \ - '$(PERLDOC_PAGER=cat "$1" -u perl | \ - command sed -ne "/perl.*Perl overview/,/perlwin32/p" | \ - awk "\$NF=2 && \$1 ~ /^perl/ { print \$1 }")' \ - -- "$cur")) + _comp_compgen -a split -- "$(PERLDOC_PAGER=cat "$1" -u perl | + command sed -ne '/perl.*Perl overview/,/perlwin32/p' | + _comp_awk 'NF >= 2 && $1 ~ /^perl/ { print $1 }')" fi fi - _filedir 'p@([lm]|od)' + _comp_compgen -a filedir 'p@([lm]|od)' fi } && - complete -F _perldoc -o bashdefault perldoc + complete -F _comp_cmd_perldoc -o bashdefault perldoc # ex: filetype=sh diff --git a/completions/perlcritic b/completions/perlcritic index 7843549..d368203 100644 --- a/completions/perlcritic +++ b/completions/perlcritic @@ -1,9 +1,9 @@ # perlcritic(1) completion -*- shell-script -*- -_perlcritic() +_comp_cmd_perlcritic() { - local cur prev words cword - _init_completion || return + local cur prev words cword comp_args + _comp_initialize -- "$@" || return case $prev in --help | --version | --top | --include | --exclude | --single-policy | \ @@ -11,41 +11,38 @@ _perlcritic() return ;; --severity) - COMPREPLY=($(compgen -W "{1..5} brutal cruel harsh stern gentle" \ - -- "$cur")) + _comp_compgen -- -W '{1..5} brutal cruel harsh stern gentle' return ;; --profile | -p) - _filedir perlcriticrc + _comp_compgen_filedir perlcriticrc return ;; --theme) - COMPREPLY=($(compgen -W '$("$1" --list-themes 2>/dev/null)' \ - -- "$cur")) + _comp_compgen_split -- "$("$1" --list-themes 2>/dev/null)" return ;; --profile-strictness) - COMPREPLY=($(compgen -W 'warn fatal quiet' -- "$cur")) + _comp_compgen -- -W 'warn fatal quiet' return ;; --verbose) - COMPREPLY=($(compgen -W '{1..11}' -- "$cur")) + _comp_compgen -- -W '{1..11}' return ;; --pager) - compopt -o filenames - COMPREPLY=($(compgen -c -- "$cur")) + _comp_compgen_commands return ;; esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_usage "$1")' -- "$cur")) + _comp_compgen_usage return fi - _filedir 'p[lm]' + _comp_compgen_filedir 'p[lm]' } && - complete -F _perlcritic perlcritic + complete -F _comp_cmd_perlcritic perlcritic # ex: filetype=sh diff --git a/completions/perltidy b/completions/perltidy index 4404cf8..5be5281 100644 --- a/completions/perltidy +++ b/completions/perltidy @@ -1,41 +1,49 @@ # perltidy(1) completion -*- shell-script -*- -_perltidy() +_comp_cmd_perltidy() { - local cur prev words cword - _init_completion -n = || return + local cur prev words cword comp_args + _comp_initialize -n = -- "$@" || return case $prev in -h | --help) return ;; -o) - _filedir + _comp_compgen_filedir return ;; esac case $cur in - -pro=*) - cur="${cur#*=}" - _filedir + -pro=* | --profile=*) + _comp_compgen -c "${cur#*=}" filedir return ;; - -ole=*) - COMPREPLY=($(compgen -W 'dos win mac unix' -- "${cur#*=}")) + -ole=* | --output-line-ending=*) + _comp_compgen -c "${cur#*=}" -- -W 'dos win mac unix' return ;; - -bt=* | -pt=* | -sbt=* | -bvt=* | -pvt=* | -sbvt=* | -bvtc=* | -pvtc=* | -sbvtc=* | \ - -cti=* | -kbl=* | -vt=*) - COMPREPLY=($(compgen -W '0 1 2' -- "${cur#*=}")) + -bt=* | --brace-tightness=* | -pt=* | --paren-tightness=* | \ + -sbt=* | --square-bracket-tightness=* | \ + -bvt=* | --brace-vertical-tightness=* | \ + -pvt=* | --paren-vertical-tightness=* | \ + -sbvt=* | --square-bracket-vertical-tightness=* | \ + -bvtc=* | --brace-vertical-tightness-closing=* | \ + -pvtc=* | --paren-vertical-tightness-closing=* | \ + -sbvtc=* | --square-bracket-vertical-tightness-closing=* | \ + -cti=* | --closing-token-indentation=* | \ + -kbl=* | --keep-old-blank-lines=* | \ + -vt=* | --vertical-tightness=*) + _comp_compgen -c "${cur#*=}" -- -W '0 1 2' return ;; - -vtc=*) - COMPREPLY=($(compgen -W '0 1' -- "${cur#*=}")) + -vtc=* | --vertical-tightness-closing=*) + _comp_compgen -c "${cur#*=}" -- -W '0 1' return ;; - -cab=*) - COMPREPLY=($(compgen -W '0 1 2 3' -- "${cur#*=}")) + -cab=* | --comma-arrow-breakpoints=*) + _comp_compgen -c "${cur#*=}" -- -W '0 1 2 3' return ;; -*=) @@ -44,12 +52,12 @@ _perltidy() esac if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else - _filedir 'p[lm]|t' + _comp_compgen_filedir 'p[lm]|t' fi } && - complete -F _perltidy perltidy + complete -F _comp_cmd_perltidy perltidy # ex: filetype=sh |