From 402a0706a586c831449a122bda6aaf5fee125a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Fri, 22 May 2009 00:22:48 +0300 Subject: [PATCH] Use _split_longopt with mc, other small mc option completion improvements. --- CHANGES | 4 ++-- contrib/mc | 34 +++++++++++++++++----------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/CHANGES b/CHANGES index 8d110349..2964d88d 100644 --- a/CHANGES +++ b/CHANGES @@ -38,8 +38,8 @@ bash-completion (1.x) * Add _split_longopt() helper for improved handling of long options that take arguments in both "--foo bar" and "--foo=bar" formats. * Use _split_longopt to improve and clean up aspell, chgrp, chown, chkconfig, - cpio, iptables, make, mii-diag, mii-tool, mkinitrd, smartctl, and generic - long option completion (Alioth: #311398). + cpio, iptables, make, mc, mii-diag, mii-tool, mkinitrd, smartctl, and + generic long option completion (Alioth: #311398). * Add chown --from and --reference value completions. * Add chgrp --reference value completion. * Do not assume all --foo= options take filenames in generic long option diff --git a/contrib/mc b/contrib/mc index 4c9fc2d2..96de7fbf 100644 --- a/contrib/mc +++ b/contrib/mc @@ -6,38 +6,38 @@ have mc && _mc() { - local cur prev + local cur prev split=false COMPREPLY=() cur=`_get_cword` prev=${COMP_WORDS[COMP_CWORD-1]} - # -name value style option + _split_longopt && split=true + case "$prev" in - -@(e|v|l|P)) + -e|--edit|-v|--view|-l|--ftplog|-P|--printwd) _filedir return 0 ;; + -C|--colors|-D|--debuglevel) + # argument required but no completions available + return 0 + ;; + -h|--help|-V|--version) + # all other arguments are noop with these + return 0 + ;; esac - # --name=value style option - if [[ "$cur" == *=* ]]; then - prev=${cur/=*/} - cur=${cur/*=/} - case "$prev" in - --@(edit|view|ftplog|printwd)) - _filedir - return 0 - ;; - esac - fi + $split && return 0 if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-a --stickchars -b --nocolor -c \ - --color -C --colors= -d --nomouse -e --edit= -f \ - --datadir -k --resetsoft -l --ftplog= -P --printwd= \ + --color -C --colors -d --nomouse -e --edit -f \ + --datadir -k --resetsoft -l --ftplog -P --printwd \ -s --slow -t --termcap -u --nosubshell -U --subshell \ - -v --view= -V --version -x --xterm -h --help' -- $cur ) ) + -v --view -V --version -x --xterm -D --debuglevel -h \ + --help' -- $cur ) ) else _filedir -d fi