summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorKim Hagen <kim.sidney@gmail.com>2016-02-05 16:04:02 -0500
committerKim Hagen <kim.sidney@gmail.com>2016-02-05 16:04:02 -0500
commitcb23703a554a919d945bf0c96811b9676ba61cd9 (patch)
tree8272d5fdf674fac64e80fcf07a1801fbe2c40469 /etc
parent9750fcafbe285b70efa56f91f04d2e8151563d2f (diff)
downloadvyatta-cfg-cb23703a554a919d945bf0c96811b9676ba61cd9.tar.gz
vyatta-cfg-cb23703a554a919d945bf0c96811b9676ba61cd9.zip
Add function to bash-completion script to fix message "bad array subs cript"
Diffstat (limited to 'etc')
-rwxr-xr-xetc/bash_completion.d/vyatta-cfg47
1 files changed, 45 insertions, 2 deletions
diff --git a/etc/bash_completion.d/vyatta-cfg b/etc/bash_completion.d/vyatta-cfg
index e6c1842..22f9dd3 100755
--- a/etc/bash_completion.d/vyatta-cfg
+++ b/etc/bash_completion.d/vyatta-cfg
@@ -129,7 +129,7 @@ vyatta_run_complete ()
COMP_WORDS=( "${COMP_WORDS[@]:1}" )
(( COMP_CWORD -= 1 ))
if [[ ${COMP_WORDS[0]} =~ "/" ]]; then
- _filedir_xspec
+ _filedir_xspec_vyos
else
shopt -s extglob nullglob
_vyatta_op_expand "$@"
@@ -1080,10 +1080,53 @@ vyatta_config_default_complete ()
else
# after the first word => cannot be vyatta command so use original default
compopt -o filenames
- _filedir_xspec
+ _filedir_xspec_vyos
fi
}
+_filedir_xspec_vyos()
+
+{
+ local cur prev words cword
+ _init_completion || return
+
+ _tilde "$cur" || return 0
+
+ local IFS=$'\n' xspec=${_xspec[${1##*/}]} tmp
+ local -a toks
+
+ toks=( $(
+ compgen -d -- "$(quote_readline "$cur")" | {
+ while read -r tmp; do
+ printf '%s\n' $tmp
+ done
+ }
+ ))
+
+ # Munge xspec to contain uppercase version too
+ # http://thread.gmane.org/gmane.comp.shells.bash.bugs/15294/focus=15306
+ eval xspec="${xspec}"
+ local matchop=!
+ if [[ $xspec == !* ]]; then
+ xspec=${xspec#!}
+ matchop=@
+ fi
+ xspec="$matchop($xspec|${xspec^^})"
+
+ toks+=( $(
+ eval compgen -f -X "!$xspec" -- "\$(quote_readline "\$cur")" | {
+ while read -r tmp; do
+ [[ -n $tmp ]] && printf '%s\n' $tmp
+ done
+ }
+ ))
+
+ if [[ ${#toks[@]} -ne 0 ]]; then
+ compopt -o filenames
+ COMPREPLY=( "${toks[@]}" )
+ fi
+}
+
_vyatta_cfg_init
# Local Variables: