@@ -60,19 +60,19 @@ _comp_cmd_aptitude()
6060 esac
6161
6262 if [[ $cur == -* ]]; then
63- local opts= " $( " $1 " --help 2>&1 | command sed -e \
64- ' s/--with(out)-recommends/--without-recommends\n--with-recommends/' |
65- _parse_help - | tr ' \n ' ' ' ) "
63+ _comp_compgen -R help - <<< " $(" $1 " --help 2>&1 | command sed -e \
64+ 's/--with(out)-recommends/--without-recommends\n--with-recommends/') "
65+ (( ${ # COMPREPLY[@]} )) || return 0
6666
6767 # Exclude some mutually exclusive options
68+ local exclude_flags=" "
6869 for i in " ${words[@]} " ; do
69- [[ $i == -u ]] && opts= ${opts / -i / }
70- [[ $i == -i ]] && opts= ${opts / -u / }
70+ [[ $i == -u ]] && exclude_flags+=i
71+ [[ $i == -i ]] && exclude_flags+=u
7172 done
7273
7374 # Do known short -> long replacements; at least up to 0.8.12, --help
7475 # outputs mostly only short ones.
75- COMPREPLY=($opts )
7676 for i in " ${! COMPREPLY[@]} " ; do
7777 case ${COMPREPLY[i]} in
7878 -h) COMPREPLY[i]=--help ;;
@@ -92,8 +92,8 @@ _comp_cmd_aptitude()
9292 esac
9393 done
9494
95- (( ${ # COMPREPLY[@]})) &&
96- _comp_compgen -- -W ' "${COMPREPLY[@]}" '
95+ _comp_compgen -- -W ' "${ COMPREPLY[@]}" ' \
96+ ${exclude_flags : +-X " -[ $exclude_flags ] " }
9797 else
9898 _comp_compgen -- -W ' update upgrade safe-upgrade forget-new clean
9999 autoclean install reinstall remove hold unhold purge markauto
0 commit comments