Find the answer to your Linux question:
Results 1 to 10 of 10
The 'set' command is supposed to display all the set environment variables. When I use it, it shows a lot of stuff in output. The output is so much that ...
  1. #1
    Just Joined!
    Join Date
    Oct 2008
    Location
    Bhubaneswar, Bangalore, INDIA
    Posts
    22

    'set' shell builtin

    The 'set' command is supposed to display all the set environment variables.

    When I use it, it shows a lot of stuff in output. The output is so much that even when I scroll all the way up in terminal, I cannot access some of the initial lines of the output.

    In fact, at first, I was left wondering whether 'set' command actually does what is mentioned in books, because the environment variables were in the first few lines of output which was not accessible for me.
    After redirecting the output to a text file, I saw that the 1st few lines contained the ENV variables.
    This gave rise to two questions in my mind.

    1) What is the limit on the number of lines that a terminal can access (limit of lines we can reach by scrolling)?

    2) What does the rest of the output do (containing lots of loops and other stuff)? (Rather than a very technical answer, a hand-waving general answer will be more illuminating.)

    Code:
    BASH=/bin/bash
    BASH_ARGC=()
    BASH_ARGV=()
    BASH_COMPLETION=/etc/bash_completion
    BASH_COMPLETION_DIR=/etc/bash_completion.d
    BASH_LINENO=()
    BASH_SOURCE=()
    BASH_VERSINFO=([0]="3" [1]="2" [2]="39" [3]="1" [4]="release" [5]="i486-pc-linux-gnu")
    BASH_VERSION='3.2.39(1)-release'
    COLORTERM=gnome-terminal
    COLUMNS=80
    DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-QtPFKoKr7R,guid=dac2629f83735975f703161149a3b5f6
    DESKTOP_SESSION=default
    DIRSTACK=()
    DISPLAY=:0.0
    EUID=1000
    GDMSESSION=default
    GDM_LANG=en_IN
    GDM_XSERVER_LOCATION=local
    GNOME_DESKTOP_SESSION_ID=this-is-deprecated
    GNOME_KEYRING_PID=5695
    GNOME_KEYRING_SOCKET=/tmp/keyring-edikmC/socket
    GPG_AGENT_INFO=/tmp/seahorse-bzMEku/S.gpg-agent:5807:1
    GROUPS=()
    GTK_RC_FILES=/etc/gtk/gtkrc:/home/soumyashant/.gtkrc-1.2-gnome2
    HISTCONTROL=ignoreboth
    HISTFILE=/home/soumyashant/.bash_history
    HISTFILESIZE=500
    HISTSIZE=500
    HOME=/home/soumyashant
    HOSTNAME=soumyashant-laptop
    HOSTTYPE=i486
    IFS=$' \t\n'
    LANG=en_IN
    LESSCLOSE='/usr/bin/lesspipe %s %s'
    LESSOPEN='| /usr/bin/lesspipe %s'
    LINES=24
    LOGNAME=soumyashant
    LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:'
    MACHTYPE=i486-pc-linux-gnu
    MAILCHECK=60
    OPTERR=1
    OPTIND=1
    ORBIT_SOCKETDIR=/tmp/orbit-soumyashant
    OSTYPE=linux-gnu
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    PIPESTATUS=([0]="0")
    PPID=964
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    PS2='> '
    PS4='+ '
    PWD=/home/soumyashant
    SESSION_MANAGER=local/soumyashant-laptop:/tmp/.ICE-unix/5706
    SHELL=/bin/bash
    SHELLOPTS=braceexpand:emacs:hashall:histexpand:interactive-comments:monitor
    SHLVL=1
    SSH_AUTH_SOCK=/tmp/keyring-edikmC/ssh
    TERM=xterm
    UID=1000
    USER=soumyashant
    USERNAME=soumyashant
    WINDOWID=60839929
    WINDOWPATH=7
    XAUTHORITY=/home/soumyashant/.Xauthority
    XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/
    XDG_SESSION_COOKIE=035af515cb9268db46576966492aa9a4-1235465716.637513-192918444
    _=set
    __pkcon_commandlist=$'\n    accept-eula\n    get-actions\n    get-depends\n    get-details\n    get-distro-upgrades\n    get-files\n    get-filters\n    get-groups\n    get-packages\n    download\n    get-requires\n    get-time\n    get-transactions\n    get-update-detail\n    get-updates\n    install\n    refresh\n    remove\n    repo-disable\n    repo-enable\n    repo-list\n    repo-set-data\n    resolve\n    search\n    update\n    '
    bash205='3.2.39(1)-release'
    bash205b='3.2.39(1)-release'
    bash3='3.2.39(1)-release'
    __pkconcomp () 
    { 
        local all c s='
    ' IFS=' ''	''
    ';
        local cur="${COMP_WORDS[COMP_CWORD]}";
        if [ $# -gt 2 ]; then
            cur="$3";
        fi;
        for c in $1;
        do
            case "$c$4" in 
                *.)
                    all="$all$c$4$s"
                ;;
                *)
                    all="$all$c$4 $s"
                ;;
            esac;
        done;
        IFS=$s;
        COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"));
        return
    }
    _alias () 
    { 
        local cur;
        COMPREPLY=();
        cur=${COMP_WORDS[$COMP_CWORD]};
        case "$COMP_LINE" in 
            *[^=])
                COMPREPLY=($( compgen -A alias -S '=' -- $cur ))
            ;;
            *=)
                COMPREPLY=("$( alias ${cur%=} 2>/dev/null | 			     sed -e 's|^alias '$cur'\(.*\)$|\1|' )")
            ;;
        esac
    }
    _ant () 
    { 
        local cur prev buildfile i;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case "$prev" in 
            -buildfile | -f)
                _filedir 'xml';
                return 0
            ;;
            -logfile)
                _filedir;
                return 0
            ;;
        esac;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-help -projecthelp -version -quiet \
    			       -verbose -debug -emacs -logfile -logger \
    			       -listener -buildfile -f -D -find' -- $cur ));
        else
            buildfile=build.xml;
            for ((i=1; i < COMP_CWORD; i++ ))
            do
                if [[ "${COMP_WORDS[i]}" == -buildfile ]]; then
                    buildfile=${COMP_WORDS[i+1]};
                    break;
                fi;
            done;
            [ ! -f $buildfile ] && return 0;
            COMPREPLY=($( awk -F'"' '/<target name="/ {print $2}' 				$buildfile | grep "^$cur" ) $( awk -F"'" "/<target name='/ "'{print $2}' 				$buildfile | grep "^$cur" ) $( awk -F'"' '/<target [^n]/ {if ($1 ~ /name=/) { print $2 } else if ($3 ~ /name=/) {print $4} else if ($5 ~ /name=/) {print $6}}' 				$buildfile | grep "^$cur" ));
        fi
    }
    _apt_cache () 
    { 
        local cur prev special i;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        if [ "$cur" != show ]; then
            for ((i=0; i < ${#COMP_WORDS[@]}-1; i++ ))
            do
                if [[ ${COMP_WORDS[i]} == @(add|depends|dotty|policy|rdepends|madison|show?(pkg|src|)) ]]; then
                    special=${COMP_WORDS[i]};
                fi;
            done;
        fi;
        if [ -n "$special" ]; then
            case $special in 
                add)
                    _filedir;
                    return 0
                ;;
                *)
                    COMPREPLY=($( apt-cache pkgnames $cur 2> /dev/null ));
                    return 0
                ;;
            esac;
        fi;
        case "$prev" in 
            -@(c|p|s|-config-file|-@(pkg|src)-cache))
                _filedir;
                return 0
            ;;
            search)
                if [[ "$cur" != -* ]]; then
                    return 0;
                fi
            ;;
        esac;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-h -v -p -s -q -i -f -a -g -c \
    				-o --help --version --pkg-cache --src-cache \
    				--quiet --important --full --all-versions \
    				--no-all-versions --generate --no-generate \
    				--names-only --all-names --recurse \
    				--config-file --option' -- $cur ));
        else
            COMPREPLY=($( compgen -W 'add gencaches show showpkg showsrc \
    				stats dump dumpavail unmet search search \
    				depends rdepends pkgnames dotty xvcg \
    				policy madison' -- $cur ));
        fi;
        return 0
    }
    _apt_get () 
    { 
        local cur prev special i;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        for ((i=0; i < ${#COMP_WORDS[@]}-1; i++ ))
        do
            if [[ ${COMP_WORDS[i]} == @(install|remove|purge|source|build-dep) ]]; then
                special=${COMP_WORDS[i]};
            fi;
        done;
        if [ -n "$special" ]; then
            case $special in 
                remove | purge)
                    if [ -f /etc/debian_version ]; then
                        COMPREPLY=($( _comp_dpkg_installed_packages 						$cur ));
                    else
                        _rpm_installed_packages;
                    fi;
                    return 0
                ;;
                *)
                    COMPREPLY=($( apt-cache pkgnames $cur 2> /dev/null ));
                    return 0
                ;;
            esac;
        fi;
        case "$prev" in 
            -@(c|-config-file))
                _filedir;
                return 0
            ;;
            -@(t|-target-release|-default-release))
                COMPREPLY=($( apt-cache policy | 				    grep "release.o=Debian,a=$cur" | 				    sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null));
                return 0
            ;;
        esac;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-d -f -h -v -m -q -s -y \
    				-u -t -b -c -o --download-only --fix-broken \
    				--help --version --ignore-missing \
    				--fix-missing --no-download --quiet --simulate \
    				--just-print --dry-run --recon --no-act --yes \
    				--assume-yes --show-upgraded --only-source \
    				--compile --build --ignore-hold \
    				--target-release --no-upgrade --force-yes \
    				--print-uris --purge --reinstall \
    				--list-cleanup --default-release \
    				--trivial-only --no-remove --diff-only \
    				--tar-only --config-file --option --auto-remove' -- $cur ));
        else
            COMPREPLY=($( compgen -W 'update upgrade dselect-upgrade \
    				dist-upgrade install remove purge source \
    				build-dep check clean autoclean autoremove' 				-- $cur ));
        fi;
        return 0
    }
    _aptitude () 
    { 
        local cur dashoptions prev special i;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        dashoptions='-S -u -i -h --help --version -s --simulate -d \
    		     --download-only -P --prompt -y --assume-yes -F \
    		     --display-format -O --sort -w --width -f -r -g \
    		     --with-recommends --with-suggests -R -G \
    		     --without-recommends --without-suggests -t \
    		     --target-release -V --show-versions -D --show-deps\
    		     -Z -v --verbose --purge-unused';
        for ((i=0; i < ${#COMP_WORDS[@]}-1; i++ ))
        do
            if [[ ${COMP_WORDS[i]} == @(install|reinstall|hold|unhold|markauto|unmarkauto|dist-upgrade|full-upgrade|download|show|forbid-version|purge|remove|changelog|why|why-not|keep|keep-all) ]]; then
                special=${COMP_WORDS[i]};
            fi;
            [[ ${COMP_WORDS[i]} == '-u' ]] && dashoptions=${dashoptions/-i};
            [[ ${COMP_WORDS[i]} == '-i' ]] && dashoptions=${dashoptions/-u};
        done;
        if [[ -n "$special" ]]; then
            case $special in 
                @(install|hold|markauto|unmarkauto|dist-upgrade|full-upgrade|download|show|changelog|why|why-not))
                    COMPREPLY=($( apt-cache pkgnames $cur 2> /dev/null ));
                    return 0
                ;;
                @(purge|remove|reinstall|forbid-version))
                    COMPREPLY=($( _comp_dpkg_installed_packages $cur ));
                    return 0
                ;;
                unhold)
                    COMPREPLY=($( _comp_dpkg_hold_packages $cur ));
                    return 0
                ;;
            esac;
        fi;
        case $prev in 
            @(autoclean|clean|forget-new|search|upgrade|safe-upgrade|update|keep-all))
                return 0
            ;;
            -S)
                _filedir;
                return 0
            ;;
            -@(t|-target-release|-default-release))
                COMPREPLY=($( apt-cache policy | 		    grep "release.o=Debian,a=$cur" | 		    sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null ));
                return 0
            ;;
        esac;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W "$dashoptions" -- $cur ));
        else
            COMPREPLY=($( compgen -W 'update upgrade safe-upgrade forget-new clean \
    				       autoclean install reinstall remove \
    				       hold unhold purge markauto unmarkauto why why-not \
    				       dist-upgrade full-upgrade download search show \
    				       forbid-version changelog keep-all' -- $cur ));
        fi;
        return 0
    }
    _aspell () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case "$prev" in 
            @(-c|-p|check))
                _filedir;
                return 0
            ;;
            @(dump|create|merge))
                COMPREPLY=($( compgen -W 'master personal repl' -- $cur ));
                return 0
            ;;
            -d)
                _aspell_dictionary;
                return 0
            ;;
        esac;
        if [[ "$cur" == *=* ]]; then
            prev=${cur/=*/};
            cur=${cur/*=/};
            case "$prev" in 
                --@(conf|personal|repl|per-conf))
                    _filedir;
                    return 0
                ;;
                --@(conf-dir|data-dir|dict-dir|home-dir|local-data-dir|prefix))
                    _filedir -d;
                    return 0
                ;;
                --master)
                    _aspell_dictionary;
                    return 0
                ;;
                --mode)
                    COMPREPLY=($( compgen -W 'none url email sgml tex' -- $cur ));
                    return 0
                ;;
                --sug-mode)
                    COMPREPLY=($( compgen -W 'ultra fast normal bad-speller' -- $cur ));
                    return 0
                ;;
                --keymapping)
                    COMPREPLY=($( compgen -W 'aspell ispell' -- $cur ));
                    return 0
                ;;
            esac;
        fi;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '--conf= --conf-dir= --data-dir= --dict-dir= \
    			--encoding= --add-filter= --rem-filter= --mode= -e \
    			-H -t --add-extra-dicts= --rem-extra-dicts= \
    			--home-dir= -W --ignore= --ignore-accents \
    			--dont-ignore-accents --ignore-case --dont-ignore-case \
    			--ignore-repl --dont-ignore-repl --jargon= --keyboard= \
    			--lang= --language-tag= --local-data-dir= -d --master= \
    			--module= --add-module-search-order= \
    			--rem-module-search-order= --per-conf= -p --personal= \
    			--prefix= --repl= -C -B --run-together --dont-run-together \
    			--run-together-limit= --run-together-min= --save-repl \
    			--dont-save-repl --set-prefix --dont-set-prefix --size= \
    			--spelling= --strip-accents --dont-strip-accents \
    			--sug-mode= --add-word-list-path= --rem-word-list-path= \
    			-b -x --backup -b|-x --dont-backup --reverse --dont-reverse \
    			--time --dont-time --keymapping= --add-email-quote= \
    			--rem-email-quote= --email-margin= --add-tex-command= \
    			--rem-tex-command= --tex-check-comments \
    			--dont-tex-check-comments --add-tex-extension= \
    			--rem-tex-extension= --add-sgml-check= --rem-sgml-check= \
    			--add-sgml-extension= --rem-sgml-extension=' -- $cur ));
        else
            COMPREPLY=($( compgen -W '-? help -c check -a pipe -l list \
    			config config soundslike filter -v version dump \
    			create merge' -- $cur ));
        fi
    }
    _aspell_dictionary () 
    { 
        local datadir;
        datadir=/usr/lib/aspell;
        COMPREPLY=($( command ls $datadir/*.@(multi|alias) ));
        COMPREPLY=(${COMPREPLY[@]%.@(multi|alias)});
        COMPREPLY=($( compgen -W '${COMPREPLY[@]#$datadir/}' -- $cur ))
    }
    _available_interfaces () 
    { 
        local cmd;
        if [ "${1:-}" = -w ]; then
            cmd="iwconfig";
        else
            if [ "${1:-}" = -a ]; then
                cmd="ifconfig";
            else
                cmd="ifconfig -a";
            fi;
        fi;
        COMPREPLY=($( eval $cmd 2>/dev/null | 		sed -ne 's|^\('$cur'[^[:space:][:punct:]]\{1,\}\).*$|\1|p'))
    }
    _bzip2 () 
    { 
        local cur prev xspec IFS='	
    ';
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-c -d -f -h -k -L -q -s \
    			-t -v -V -z -1 -2 -3 -4 -5 -6 -7 -8 -9 \
    			--help --decompress --compress --keep --force \
    			--test --stdout --quiet --verbose --license \
    			--version --small --fast --best' -- $cur ));
            return 0;
        fi;
        xspec="*.bz2";
        if [[ "$prev" == --* ]]; then
            [[ "$prev" == --decompress || "$prev" == --list || "$prev" == --test ]] && xspec="!"$xspec;
            [[ "$prev" == --compress ]] && xspec=;
        else
            if [[ "$prev" == -* ]]; then
                [[ "$prev" == -*[dt]* ]] && xspec="!"$xspec;
                [[ "$prev" == -*z* ]] && xspec=;
            fi;
        fi;
        _expand || return 0;
        COMPREPLY=($( compgen -f -X "$xspec" -- $cur ) $( compgen -d -- $cur ))
    }
    _cancel () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        COMPREPLY=($( lpstat | cut -d' ' -f1 | grep "^$cur" ))
    }
    _cd () 
    { 
        local IFS='	
    ' cur=`_get_cword` i j k;
        if [[ "$cur" == ?(\\)\$* ]]; then
            COMPREPLY=($( compgen -v -P '$' -- "${cur#?(\\)$}" ));
            return 0;
        fi;
        if [ -z "${CDPATH:-}" ] || [[ "$cur" == ?(.)?(.)/* ]]; then
            _filedir -d;
            return 0;
        fi;
        local -r mark_dirs=$(_rl_enabled mark-directories && echo y);
        local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y);
        for i in ${CDPATH//:/'	'};
        do
            k="${#COMPREPLY[@]}";
            for j in $( compgen -d $i/$cur );
            do
                if [[ ( -n $mark_symdirs && -h $j || -n $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then
                    j="${j}/";
                fi;
                COMPREPLY[k++]=${j#$i/};
            done;
        done;
        _filedir -d;
        if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
            i=${COMPREPLY[0]};
            if [ "$i" == "$cur" ] && [[ $i != "*/" ]]; then
                COMPREPLY[0]="${i}/";
            fi;
        fi;
        return 0
    }
    _cdrecord () 
    { 
        local cur prev i generic_options track_options track_mode;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        if [[ "$cur" == *=* ]]; then
            prev=${cur/=*/};
            cur=${cur/*=/};
            case "$prev" in 
                @(text|cue)file)
                    _filedir;
                    return 0
                ;;
                blank)
                    COMPREPLY=($( compgen -W 'help all fast \
    				track unreserve trtail unclose session' 				-- $cur ));
                    return 0
                ;;
                driveropts)
                    COMPREPLY=($( compgen -W 'burnfree noburnfree\
    				  varirec= audiomaster forcespeed noforcespeed\
    				  speedread nospeedread singlesession \
    				  nosinglesession hidecdr nohidecdr tattooinfo\
    				  tattoofile=' -- $cur ));
                    return 0
                ;;
            esac;
        fi;
        generic_options=(-version -v -V -d -silent -s -force -immed -dummy -dao -raw -raw96r -raw96p -raw16 -multi -msinfo -toc -atip -fix -nofix -waiti -load -lock -eject -format -setdropts -checkdrive -prcap -inq -scanbus -reset -abort -overburn -ignsize -useinfo -packet -noclose -text debug= kdebug= kd= minbuf= speed= blank= fs= dev= gracetime= timeout= driver= driveropts= defpregap= pktsize= mcn= textfile= cuefile=);
        track_options=(-audio -swab -data -mode2 -xa -xa1 -xa2 -xamix -cdi -isosize -pad padsize= -nopad -shorttrack -noshorttrack pregap= -preemp -nopreemp -copy -nocopy -scms tcsize= isrc= index=);
        track_mode=0;
        if [ $COMP_CWORD -gt 1 ]; then
            if [ -f "$prev" ]; then
                track_mode=1;
            else
                for ((i=0; i < ${#track_options[@]}; i++ ))
                do
                    if [[ "${track_options[i]}" == "$prev" ]]; then
                        track_mode=1;
                        break;
                    fi;
                done;
            fi;
        fi;
        _filedir;
        COMPREPLY=("${COMPREPLY[@]}" $( compgen -W '${track_options[@]}' -- $cur ));
        if [ $track_mode -eq 0 ]; then
            COMPREPLY=("${COMPREPLY[@]}" $( compgen -W '${generic_options[@]}' -- $cur ));
        fi
    }
    _chgrp () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        cur=${cur//\\\\/};
        prev=${COMP_WORDS[COMP_CWORD-1]};
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-c -h -f -R -v --changes \
    		--dereference --no-dereference --silent --quiet \
    		--reference= --recursive --verbose --help --version' -- $cur ));
            return 0;
        fi;
        if [ $COMP_CWORD -eq 1 ] && [[ "$cur" != -* ]] || [[ "$prev" == -* ]] && [ -n "$bash205" ]; then
            local IFS='
    ';
            COMPREPLY=($( compgen -g $cur 2>/dev/null ));
        else
            _filedir || return 0;
        fi;
        return 0
    }
    _chown () 
    { 
        local cur;
        cur=`_get_cword`;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-c -h -f -R -v --changes \
    		--dereference --no-dereference --from= --silent --quiet \
    		--reference= --recursive --verbose --help --version' -- $cur ));
        else
            _count_args;
            case $args in 
                1)
                    _usergroup
                ;;
                *)
                    _filedir
                ;;
            esac;
        fi
    }
    _chsh () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        if [ "$prev" = "-s" ]; then
            if [ -f /etc/debian_version ]; then
                COMPREPLY=($( </etc/shells ));
            else
                COMPREPLY=($( chsh -l | grep "^$cur" ));
            fi;
        else
            COMPREPLY=($( compgen -u -- $cur ));
        fi;
        return 0
    }
    _command () 
    { 
        local cur func cline cspec noglob cmd done i _COMMAND_FUNC _COMMAND_FUNC_ARGS;
        _remove_comp_word;
        COMPREPLY=();
        cur=`_get_cword`;
        done=;
        while [ -z $done ]; do
            cmd=${COMP_WORDS[0]};
            if [[ "$cmd" == -* ]] && [ $COMP_CWORD -ge 1 ]; then
                _remove_comp_word;
            else
                if [[ "$cmd" == -* ]] && [[ $COMP_CWORD -eq 0 ]]; then
                    return;
                else
                    done=1;
                fi;
            fi;
        done;
        if [ $COMP_CWORD -eq 0 ]; then
            COMPREPLY=($( compgen -c -- $cur ));
        else
            if complete -p $cmd >&/dev/null; then
                cspec=$( complete -p $cmd );
                if [ "${cspec#* -F }" != "$cspec" ]; then
                    func=${cspec#*-F };
                    func=${func%% *};
                    if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
                        $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" "${COMP_WORDS[${#COMP_WORDS[@]}-2]}";
                    else
                        $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}";
                    fi;
                    if [ "${cspec#*-o }" != "$cspec" ]; then
                        cspec=${cspec#*-o };
                        cspec=${cspec%% *};
                        if [[ "$cspec" != @(dir|file)names ]]; then
                            COMPREPLY=("${COMPREPLY[@]//\\\\:/:}");
                        fi;
                    fi;
                else
                    if [ -n "$cspec" ]; then
                        cspec=${cspec#complete};
                        cspec=${cspec%%$cmd};
                        COMPREPLY=($( eval compgen "$cspec" -- "$cur" ));
                    fi;
                fi;
            fi;
        fi;
        [ ${#COMPREPLY[@]} -eq 0 ] && _filedir
    }
    _comp_dpkg_hold_packages () 
    { 
        grep -B 2 'hold' /var/lib/dpkg/status | grep "Package: $1" | cut -d\  -f2
    }
    _comp_dpkg_installed_packages () 
    { 
        grep -A 1 "Package: $1" /var/lib/dpkg/status | grep -B 1 -E "ok installed|half-installed|unpacked|        			      half-configured|config-files" | grep "Package: $1" | cut -d\  -f2
    }
    _complete () 
    { 
        local cur prev options;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case $prev in 
            -o)
                options="default dirnames filenames";
                [ -n "$bash205b" ] && options="$options nospace";
                [ -n "$bash3" ] && options="$options bashdefault plusdirs";
                COMPREPLY=($( compgen -W "$options" -- $cur ));
                return 0
            ;;
            -A)
                COMPREPLY=($( compgen -W 'alias arrayvar binding \
    				builtin command directory disabled enabled \
    				export file function group helptopic hostname \
    				job keyword running service setopt shopt \
    				signal stopped user variable' -- $cur ));
                return 0
            ;;
            -C)
                COMPREPLY=($( compgen -A command -- $cur ));
                return 0
            ;;
            -F)
                COMPREPLY=($( compgen -A function -- $cur ));
                return 0
            ;;
            -@(p|r))
                COMPREPLY=($( complete -p | sed -e 's|.* ||' | 					grep "^$cur" ));
                return 0
            ;;
        esac;
        if [[ "$cur" == -* ]]; then
            options="-a -b -c -d -e -f -g -j -k -s -v -u -A -G -W -P -S -X -F -C";
            [ -n "$bash205" ] && options="$options -o";
            COMPREPLY=($( compgen -W "$options" -- $cur ));
        else
            COMPREPLY=($( compgen -A command -- $cur ));
        fi
    }
    _configure_func () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        [[ "$cur" != -* ]] && return 0;
        if [ -n "$COMP_CONFIGURE_HINTS" ]; then
            COMPREPLY=($( $1 --help | awk '/^  --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,].*//g' | grep ^$cur ));
        else
            COMPREPLY=($( $1 --help | awk '/^  --[A-Za-z]/ { print $1; if ($2 ~ /--[A-Za-z]/) print $2 }' | sed -e 's/[[,=].*//g' | grep ^$cur ));
        fi
    }
    _configured_interfaces () 
    { 
        if [ -f /etc/debian_version ]; then
            COMPREPLY=($( sed -ne 's|^iface \([^ ]\+\).*$|\1|p' 			       /etc/network/interfaces ));
        else
            if [ -f /etc/SuSE-release ]; then
                COMPREPLY=($( command ls 			/etc/sysconfig/network/ifcfg-* | 			sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ));
            else
                if [ -f /etc/pld-release ]; then
                    COMPREPLY=($( command ls -B 			/etc/sysconfig/interfaces | 			sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ));
                else
                    COMPREPLY=($( command ls 			/etc/sysconfig/network-scripts/ifcfg-* | 			sed -ne 's|.*ifcfg-\('$cur'.*\)|\1|p' ));
                fi;
            fi;
        fi
    }
    _count_args () 
    { 
        args=1;
        for ((i=1; i < COMP_CWORD; i++ ))
        do
            if [[ "${COMP_WORDS[i]}" != -* ]]; then
                args=$(($args+1));
            fi;
        done
    }
    _cpio () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case $prev in 
            -H)
                _cpio_format;
                return 0
            ;;
            -@(E|F|I))
                _filedir;
                return 0
            ;;
            -R)
                _usergroup;
                return 0
            ;;
        esac;
        if [[ "$cur" == *=* ]]; then
            prev=${cur/=*/};
            cur=${cur/*=/};
            case $prev in 
                --format)
                    _cpio_format;
                    return 0
                ;;
                --@(file|pattern-file))
                    _filedir;
                    return 0
                ;;
                --owner)
                    _usergroup;
                    return 0
                ;;
                --rsh-command)
                    COMPREPLY=($( compgen -c -- $cur ));
                    return 0
                ;;
            esac;
        fi;
        if [ $COMP_CWORD -eq 1 ]; then
            COMPREPLY=($( compgen -W '-o --create -i --extract -p --pass-through' -- $cur));
        else
            case ${COMP_WORDS[1]} in 
                -@(o|-create))
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-0 -a -c -v -A -B\
    						-L -V -C -H -M -O -F --file= --format=\
    						--message= --null --reset-access-time\
    						--verbose --dot --append --block-size=\
    						--dereference --io-size= --quiet\
    						--force-local --rsh-command= --help\
    						--version' -- $cur ));
                    fi
                ;;
                -@(i|-extract))
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-b -c -d -f -m -n -r\
    						-t -s -u -v -B -S -V -C -E -H -M -R -I\
    						-F --file= --make-directories\
    						--nonmatching\
    						--preserve-modification-time\
    						--numeric-uid-gid --rename -t --list\
    						--swap-bytes --swap --dot\
    						--unconditional --verbose --block-size=\
    						--swap-halfwords --io-size=\
    						--pattern-file= --format= --owner=\
    						--no-preserve-owner --message=\
    						--force-local --no-absolute-filenames\
    						--sparse --only-verify-crc --quiet\
    						--rsh-command= --help\
    						--version' -- $cur ));
                    fi
                ;;
                -@(p|-pass-through))
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-0 -a -d -l -m -u -v\
    						-L -V -R --null --reset-access-time\
    						--make-directories --link --quiet\
    						--preserve-modification-time\
    						--unconditional --verbose --dot\
    						--dereference --owner=\
    						--no-preserve-owner --sparse --help\
    						--version' -- $cur ));
                    else
                        _filedir -d;
                    fi
                ;;
            esac;
        fi
    }
    _cpio_format () 
    { 
        COMPREPLY=($( compgen -W 'bin odc newc crc tar ustar hpbin hpodc' -- $cur ))
    }
    _cvs () 
    { 
        local cur count mode i cvsroot cvsroots pwd;
        local -a flags miss files entries changed newremoved;
        COMPREPLY=();
        cur=`_get_cword`;
        count=0;
        for i in "${COMP_WORDS[@]}";
        do
            [ $count -eq $COMP_CWORD ] && break;
            if [ "${COMP_WORDS[((count))]}" == "$cvsroot" -a "$mode" == "cvsroot" ]; then
                mode="";
            fi;
            if [ -z "$mode" ]; then
                case $i in 
                    -d)
                        mode=cvsroot;
                        cvsroot=${COMP_WORDS[((count+1))]}
                    ;;
                    @(ad?(d)|new))
                        mode=add
                    ;;
                    @(adm?(in)|rcs))
                        mode=admin
                    ;;
                    ann?(notate))
                        mode=annotate
                    ;;
                    @(checkout|co|get))
                        mode=checkout
                    ;;
                    @(com?(mit)|ci))
                        mode=commit
                    ;;
                    di?(f?(f)))
                        mode=diff
                    ;;
                    ex?(p?(ort)))
                        mode=export
                    ;;
                    ?(un)edit)
                        mode=$i
                    ;;
                    hi?(s?(tory)))
                        mode=history
                    ;;
                    im?(p?(ort)))
                        mode=import
                    ;;
                    re?(l?(ease)))
                        mode=release
                    ;;
                    ?(r)log)
                        mode=log
                    ;;
                    @(rdiff|patch))
                        mode=rdiff
                    ;;
                    @(remove|rm|delete))
                        mode=remove
                    ;;
                    @(rtag|rfreeze))
                        mode=rtag
                    ;;
                    st?(at?(us)))
                        mode=status
                    ;;
                    @(tag|freeze))
                        mode=tag
                    ;;
                    up?(d?(ate)))
                        mode=update
                    ;;
                    *)
    
                    ;;
                esac;
            else
                if [[ "$i" = -* ]]; then
                    flags=("${flags[@]}" $i);
                fi;
            fi;
            count=$((++count));
        done;
        case "$mode" in 
            add)
                if [[ "$cur" != -* ]]; then
                    set_prefix;
                    if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}CVS/Entries ]; then
                        get_entries;
                        [ -z "$cur" ] && files=$( command ls -Ad !(CVS) ) || files=$( command ls -d ${cur}* 2>/dev/null );
                        for i in "${entries[@]}";
                        do
                            files=(${files[@]/#$i//});
                        done;
                        COMPREPLY=($( compgen -W '${files[@]}' -- 					       $cur ));
                    fi;
                else
                    COMPREPLY=($( compgen -W '-k -m' -- $cur ));
                fi
            ;;
            admin)
                if [[ "$cur" = -* ]]; then
                    COMPREPLY=($( compgen -W '-i -a -A -e -b -c -k -l -u \
    						   -L -U -m -M -n -N -o -q -I \
    						   -s -t -t- -T -V -x -z' -- 					$cur ));
                fi
            ;;
            annotate)
                if [[ "$cur" = -* ]]; then
                    COMPREPLY=($( compgen -W '-D -F -f -l -R -r' -- $cur ));
                else
                    get_entries;
                    COMPREPLY=($( compgen -W '${entries[@]}' -- $cur ));
                fi
            ;;
            checkout)
                if [[ "$cur" != -* ]]; then
                    [ -z "$cvsroot" ] && cvsroot=$CVSROOT;
                    COMPREPLY=($( cvs -d "$cvsroot" co -c 2> /dev/null | 					awk '{print $1}' ));
                    COMPREPLY=($( compgen -W '${COMPREPLY[@]}' -- $cur ));
                else
                    COMPREPLY=($( compgen -W '-A -N -P -R -c -f -l -n -p \
    						  -s -r -D -d -k -j' -- $cur ));
                fi
            ;;
            commit)
                set_prefix;
                if [[ "$cur" != -* ]] && [ -r ${prefix:-}CVS/Entries ]; then
                    if [ -n "${COMP_CVS_REMOTE:-}" ]; then
                        changed=($( cvs -q diff --brief 2>&1 | 				sed -ne 's/^Files [^ ]* and \([^ ]*\) differ$/\1/p' ));
                        newremoved=($( cvs -q diff --brief 2>&1 | 				sed -ne 's/^cvs diff: \([^ ]*\) .*, no comparison available$/\1/p' ));
                        COMPREPLY=($( compgen -W '${changed[@]:-} \
    						   ${newremoved[@]:-}' -- $cur ));
                    else
                        _filedir;
                    fi;
                else
                    COMPREPLY=($( compgen -W '-n -R -l -f -F -m -r' -- 				       $cur ));
                fi
            ;;
            cvsroot)
                if [ -r ~/.cvspass ]; then
                    cvsroots=$( sed 's/^[^ ]* //; s/:/\\:/g' ~/.cvspass );
                    COMPREPLY=($( compgen -W '$cvsroots' -- $cur ));
                fi
            ;;
            export)
                if [[ "$cur" != -* ]]; then
                    [ -z "$cvsroot" ] && cvsroot=$CVSROOT;
                    COMPREPLY=($( cvs -d "$cvsroot" co -c | awk '{print $1}' ));
                    COMPREPLY=($( compgen -W '${COMPREPLY[@]}' -- $cur ));
                else
                    COMPREPLY=($( compgen -W '-N -f -l -R -n \
    						  -r -D -d -k' -- $cur ));
                fi
            ;;
            diff)
                if [[ "$cur" == -* ]]; then
                    _longopt diff;
                else
                    get_entries;
                    COMPREPLY=($( compgen -W '${entries[@]:-}' -- $cur ));
                fi
            ;;
            remove)
                if [[ "$cur" != -* ]]; then
                    set_prefix;
                    if [ $COMP_CWORD -gt 1 -a -r ${prefix:-}CVS/Entries ]; then
                        get_entries;
                        for i in "${entries[@]}";
                        do
                            [ ! -r "$i" ] && miss=("${miss[@]}" $i);
                        done;
                        COMPREPLY=($(compgen -W '${miss[@]:-}' -- $cur));
                    fi;
                else
                    COMPREPLY=($( compgen -W '-f -l -R' -- $cur ));
                fi
            ;;
            import)
                if [[ "$cur" != -* ]]; then
                    [ -z "$cvsroot" ] && cvsroot=$CVSROOT;
                    prefix=${cur%/*};
                    if [ -r ${cvsroot}/${prefix} ]; then
                        get_modules;
                        COMPREPLY=(${COMPREPLY[@]#$cvsroot});
                        COMPREPLY=(${COMPREPLY[@]#\/});
                    fi;
                    pwd=$( pwd );
                    pwd=${pwd##*/};
                    COMPREPLY=($( compgen -W '${COMPREPLY[@]} $pwd' -- 				       $cur ));
                else
                    COMPREPLY=($( compgen -W '-d -k -I -b -m -W' -- $cur ));
                fi
            ;;
            update)
                if [[ "$cur" = -* ]]; then
                    COMPREPLY=($( compgen -W '-A -P -C -d -f -l -R -p \
    						   -k -r -D -j -I -W' -- 						   $cur ));
                fi
            ;;
            "")
                COMPREPLY=($( compgen -W 'add admin annotate checkout ci co \
    					   commit diff delete edit export \
    					   freeze get history import log new \
    					   patch rcs rdiff release remove \
    					   rfreeze rlog rm rtag stat status \
    					   tag unedit up update -H -Q -q -b \
    					   -d -e -f -l -n -t -r -v -w -x -z \
    					   --help --version' -- $cur ))
            ;;
            *)
    
            ;;
        esac;
        return 0
    }
    _dcop () 
    { 
        local cur compstr;
        COMPREPLY=();
        cur=`_get_cword`;
        if [ -z $cur ]; then
            compstr=${COMP_WORDS[*]};
        else
            compstr=$( command echo ${COMP_WORDS[*]} | sed "s/ $cur$//" );
        fi;
        COMPREPLY=($( compgen -W '$( command $compstr | sed s/\(.*\)// )'  -- $cur ))
    }
    _dd () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        case "$cur" in 
            if=* | of=*)
                cur=${cur#*=};
                _filedir;
                return 0
            ;;
            conv=*)
                cur=${cur#*=};
                COMPREPLY=($( compgen -W 'ascii ebcdic ibm block unblock \
    				lcase notrunc ucase swab noerror sync' 				-- $cur ));
                return 0
            ;;
        esac;
        _expand || return 0;
        COMPREPLY=($( compgen -W '--help --version' -- $cur ) $( compgen -W 'bs cbs conv count ibs if obs of seek skip'				-S '=' -- $cur ))
    }
    _debconf_show () 
    { 
        local cur;
        COMPREPLY=();
        cur=${COMP_WORDS[COMP_CWORD]};
        COMPREPLY=($( compgen -W '--listowners --listdbs --db=' -- $cur ) $( apt-cache pkgnames -- $cur ))
    }
    _desktop_file_validate () 
    { 
        COMPRELY=();
        cur=${COMP_WORDS[COMP_CWORD]};
        _filedir '@(desktop)'
    }
    _dhclient () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case "$prev" in 
            -@(cf|lf|pf|sf))
                _filedir;
                return 0
            ;;
            -s)
                _known_hosts;
                return 0
            ;;
        esac;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-p -d -q -1 -r -lf -pf \
    			-cf -sf -s -g -n -nw -w' -- $cur ));
        else
            _available_interfaces;
        fi
    }
    _dkms () 
    { 
        local cur prev command module i;
        COMPREPLY=();
        cur=${COMP_WORDS[COMP_CWORD]};
        if [[ $COMP_CWORD -eq 1 ]]; then
            COMPREPLY=($( compgen -W "add remove build install uninstall 			match mkdriverdisk mktarball ldtarball mkrpm mkdeb mkdsc mkkmp 			status" -- $cur ));
        else
            prev=${COMP_WORDS[COMP_CWORD-1]};
            case $prev in 
                -m)
                    COMPREPLY=($( command ls -F /var/lib/dkms | grep '/$' | sed -e 's|/$||' | grep "^$cur" ));
                    return 0
                ;;
                -v)
                    for ((i=1; i < COMP_CWORD; i++ ))
                    do
                        if [[ "${COMP_WORDS[i]}" == -m ]]; then
                            module=${COMP_WORDS[i+1]};
                            break;
                        fi;
                    done;
                    if [ -n "$module" ]; then
                        COMPREPLY=($( command ls -F /var/lib/dkms/$module | grep '/$' | sed -e 's|/$||' | grep "^$cur" ));
                        return 0;
                    fi
                ;;
                -k)
                    _kernels;
                    return 0
                ;;
                -@\(c | -spec | -archive | -config\))
                    _filedir;
                    return 0
                ;;
                --kernelsourcedir)
                    _filedir -d;
                    return 0
                ;;
            esac;
            command=${COMP_WORDS[1]};
            if [[ "$cur" == -* ]]; then
                case $command in 
                    add)
                        options='-c --rpm_safe_upgrade'
                    ;;
                    remove)
                        options='--rpm_safe_upgrade'
                    ;;
                    build)
                        options='--config'
                    ;;
                    mkdriverdisk)
                        options='-d --distro -r --release --size'
                    ;;
                    ldtarball)
                        options='--archive --force'
                    ;;
                    mktarball)
                        options='--source-only --binaries-only'
                    ;;
                    mkrpm)
                        options='--source-only'
                    ;;
                    mkkmp)
                        options='--spec'
                    ;;
                    match)
                        options='--templatekernel'
                    ;;
                esac;
                options="$options -m -v -k -a --arch -q --quiet -V 				--version --all --no-prepare-kernel 				--no-clean-kernel --kernelsourcedir 				--directive";
                COMPREPLY=($( compgen -W "$options" -- $cur ));
            fi;
        fi
    }
    _dpkg () 
    { 
        local cur prev i;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        i=$COMP_CWORD;
        _expand || return 0;
        if [[ $cur != -* ]]; then
            while [[ $prev != -* && $i != 1 ]]; do
                i=$((i-1));
                prev=${COMP_WORDS[i-1]};
            done;
        fi;
        case "$prev" in 
            -@(c|i|A|I|f|e|x|X|-@(install|unpack|record-avail|contents|info|fsys-tarfile|field|control|extract)))
                _filedir '?(u)deb';
                return 0
            ;;
            -@(b|-build))
                _filedir -d;
                return 0
            ;;
            -@(s|p|l|-@(status|print-avail|list)))
                COMPREPLY=($( apt-cache pkgnames $cur 2>/dev/null ));
                return 0
            ;;
            -@(S|-search))
                _filedir;
                return 0
            ;;
            -@(r|L|P|-@(remove|purge|listfiles)))
                COMPREPLY=($( _comp_dpkg_installed_packages $cur ));
                return 0
            ;;
            *)
                COMPREPLY=($( compgen -W '-i --install --unpack -A --record-avail \
    			--configure -r --remove -P --purge --get-selections \
    			--set-selections --update-avail --merge-avail \
    			--clear-avail  --command-fd --forget-old-unavail -s \
    			--status -p --print-avail -L --listfiles -l --list \
    			-S --search -C --audit --print-architecture \
    			--print-gnu-build-architecture \
    			--print-installation-architecture \
    			--compare-versions --help --version --force-help \
    			--force-all --force-auto-select --force-downgrade \
    			--force-configure-any --force-hold --force-bad-path \
    			--force-not-root --force-overwrite \
    			--force-overwrite-diverted --force-bad-verify \
    			--force-depends-version --force-depends \
    			--force-confnew --force-confold --force-confdef \
    			--force-confmiss --force-conflicts --force-architecture\
    			--force-overwrite-dir --force-remove-reinstreq \
    			--force-remove-essential -Dh \
    			--debug=help --licence --admindir= --root= --instdir= \
    			-O --selected-only -E --skip-same-version \
    			-G --refuse-downgrade -B --auto-deconfigure \
    			--no-debsig --no-act -D --debug= --status-fd \
    			-b --build -I --info -f --field -c --contents \
    			-x --extract -X --vextract --fsys-tarfile -e --control \
    			--ignore-depends= --abort-after' -- $cur ))
            ;;
        esac
    }
    _dpkg_reconfigure () 
    { 
        local cur prev opt;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case "$prev" in 
            -@(f|-frontend))
                opt=($( echo /usr/share/perl5/Debconf/FrontEnd/* ));
                opt=(${opt[@]##*/});
                opt=(${opt[@]%.pm});
                COMPREPLY=($( compgen -W '${opt[@]}' -- $cur ));
                return 0
            ;;
            -@(p|-priority))
                COMPREPLY=($( compgen -W 'low medium high critical' -- $cur ));
                return 0
            ;;
        esac;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-f --frontend -p --priority -a --all \
    				       -u --unseen-only -h --help -s --showold \
    				       --force --terse' -- $cur ));
        else
            COMPREPLY=($( _comp_dpkg_installed_packages $cur ));
        fi
    }
    _dpkg_source () 
    { 
        local cur prev options work i action packopts unpackopts;
        packopts="-c -l -F -V -T -D -U -W -E -sa -i -I -sk -sp -su -sr -ss -sn -sA -sK -sP -sU -sR";
        unpackopts="-sp -sn -su";
        options=`echo "-x -b $packopts $unpackopts" | xargs echo | sort -u | xargs echo`;
        COMPREPLY=();
        if [ "$1" != "dpkg-source" ]; then
            exit 1;
        fi;
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        action="options";
        for ((i=0; i < ${#COMP_WORDS[@]}-1; i++ ))
        do
            if [[ ${COMP_WORDS[$i]} == "-x" ]]; then
                action=unpack;
            else
                if [[ ${COMP_WORDS[$i]} == "-b" ]]; then
                    action=pack;
                else
                    if [[ ${COMP_WORDS[$i]} == "-h" ]]; then
                        action=help;
                    fi;
                fi;
            fi;
        done;
        for i in $options;
        do
            if [ "$cur" = "$i" ]; then
                COMPREPLY=("$cur");
                return 0;
            fi;
        done;
        case "$action" in 
            "unpack")
                if [ "$cur" = "-" -o "$cur" = "-s" ]; then
                    COMPREPLY=($unpackots);
                    return 0;
                fi;
                case "$prev" in 
                    "-x")
                        COMPREPLY=($( compgen -d -- "$cur" ) $( compgen -f -X '!*.dsc' -- "$cur" ));
                        return 0
                    ;;
                    *)
                        COMPREPLY=($unpackopts $(compgen -d -f -- "$cur" ));
                        return 0
                    ;;
                esac;
                return 0
            ;;
            "pack")
                if [ "$cur" = "-" ]; then
                    COMPREPLY=($packopts);
                    return 0;
                fi;
                if [ "$cur" = "-s" ]; then
                    COMPREPLY=("-sa" "-sk" "-sp" "-su" "-sr" "-ss" "-sn" "-sA" "-sK" "-sP" "-sU" "-sR");
                    return 0;
                fi;
                case "$prev" in 
                    "-b")
                        COMPREPLY=($( compgen -d -- "$cur" ));
                        return 0
                    ;;
                    "-c" | "-l" | "-T" | "-i" | "-I")
                        COMPREPLY=($( compgen -d -f ));
                        return 0
                    ;;
                    "-F")
                        COMPREPLY=($( ( cd /usr/lib/dpkg/parsechangelog; compgen -f "$cur" ) ));
                        return 0
                    ;;
                    "-V" | "-D")
                        COMPREPLY=();
                        return 0
                    ;;
                    "-D")
                        if echo -- "$cur" | grep -q "="; then
                            COMPREPLY=();
                            return 0;
                        else
                            COMPREPLY=(Format Source Version Binary Maintainer Uploader Architecture Standards-Version Build-Depends Files);
                            return 0;
                        fi
                    ;;
                    "-U")
                        COMPREPLY=(Format Source Version Binary Maintainer Uploader Architecture Standards-Version Build-Depends Files);
                        return 0
                    ;;
                    *)
                        COMPREPLY=($packopts);
                        return 0
                    ;;
                esac;
                return 0
            ;;
            *)
                if [ "$cur" = "-s" ]; then
                    COMPREPLY=("-sa" "-sk" "-sp" "-su" "-sr" "-ss" "-sn" "-sA" "-sK" "-sP" "-sU" "-sR");
                    return 0;
                fi;
                COMPREPLY=($options);
                return 0
            ;;
        esac
    }
    _expand () 
    { 
        if [[ "$cur" == \~*/* ]]; then
            eval cur=$cur;
        else
            if [[ "$cur" == \~* ]]; then
                cur=${cur#\~};
                COMPREPLY=($( compgen -P '~' -u $cur ));
                return ${#COMPREPLY[@]};
            fi;
        fi
    }
    _export () 
    { 
        local cur;
        COMPREPLY=();
        cur=${COMP_WORDS[$COMP_CWORD]};
        case "$COMP_LINE" in 
            *=\$*)
                COMPREPLY=($( compgen -v -P '$' -- ${cur#*=\$} ))
            ;;
            *[^=])
                COMPREPLY=($( compgen -v -S '=' -- $cur ))
            ;;
            *=)
                COMPREPLY=("$( eval echo -n \"$`echo ${cur%=}`\" |
    			( echo -n \'
    			  sed -e 's/'\''/'\''\\\'\'''\''/g'
    			  echo -n \' ) )")
            ;;
        esac
    }
    _filedir () 
    { 
        local IFS='	
    ' xspec;
        _expand || return 0;
        local toks=() tmp;
        while read -r tmp; do
            [[ -n $tmp ]] && toks[${#toks[@]}]=$tmp;
        done < <( compgen -d -- "$(quote_readline "$cur")" );
        if [[ "$1" != -d ]]; then
            xspec=${1:+"!*.$1"};
            while read -r tmp; do
                [[ -n $tmp ]] && toks[${#toks[@]}]=$tmp;
            done < <( compgen -f -X "$xspec" -- "$(quote_readline "$cur")" );
        fi;
        COMPREPLY=("${COMPREPLY[@]}" "${toks[@]}")
    }
    _filedir_xspec () 
    { 
        local IFS cur xspec;
        IFS='	
    ';
        COMPREPLY=();
        cur=`_get_cword`;
        _expand || return 0;
        xspec=$( sed -ne '/^complete .*[ 	]'${1##*/}'\([ 	]\|$\)/{p;q;}' 		  $BASH_COMPLETION );
        xspec=${xspec#*-X };
        xspec=${xspec%% *};
        local toks=() tmp;
        while read -r tmp; do
            [[ -n $tmp ]] && toks[${#toks[@]}]=$tmp;
        done < <( compgen -d -- "$(quote_readline "$cur")" );
        while read -r tmp; do
            [[ -n $tmp ]] && toks[${#toks[@]}]=$tmp;
        done < <( eval compgen -f -X $xspec -- "\$(quote_readline "\$cur")" );
        COMPREPLY=("${toks[@]}")
    }
    _find () 
    { 
        local cur prev i exprfound onlyonce;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case "$prev" in 
            -@(max|min)depth)
                COMPREPLY=($( compgen -W '0 1 2 3 4 5 6 7 8 9' -- $cur ));
                return 0
            ;;
            -?(a|c)newer | -fls | -fprint?(0|f) | -?(i)?(l)name | -?(i)wholename)
                _filedir;
                return 0
            ;;
            -fstype)
                [ -e /proc/filesystems ] && COMPREPLY=($( cut -d'	' -f 2 /proc/filesystems | 				grep "^$cur" ));
                return 0
            ;;
            -gid)
                _gids;
                return 0
            ;;
            -group)
                if [ -n "$bash205" ]; then
                    COMPREPLY=($( compgen -g -- $cur 2>/dev/null));
                fi;
                return 0
            ;;
            -?(x)type)
                COMPREPLY=($( compgen -W 'b c d p f l s' -- $cur ));
                return 0
            ;;
            -uid)
                _uids;
                return 0
            ;;
            -user)
                COMPREPLY=($( compgen -u -- $cur ));
                return 0
            ;;
            -exec | -ok)
                COMP_WORDS=(COMP_WORDS[0] $cur);
                COMP_CWORD=1;
                _command;
                return 0
            ;;
            -[acm]min | -[acm]time | -?(i)?(l)name | -inum | -?(i)path | -?(i)regex | -links | -perm | -size | -used | -printf)
                return 0
            ;;
        esac;
        _expand || return 0;
        for i in ${COMP_WORDS[@]};
        do
            [[ "$i" = [-\(\),\!]* ]] && exprfound=1 && break;
        done;
        if [ "$exprfound" != 1 ] && [[ "$cur" != [-\(\),\!]* ]]; then
            _filedir -d;
            return 0;
        fi;
        COMPREPLY=($( compgen -W '-daystart -depth -follow -help -maxdepth \
    			-mindepth -mount -noleaf -version -xdev -amin -anewer \
    			-atime -cmin -cnewer -ctime -empty -false -fstype \
    			-gid -group -ilname -iname -inum -ipath -iregex \
    			-wholename \
    			-links -lname -mmin -mtime -name -newer -nouser \
    			-nogroup -perm -regex -size -true -type -uid -used \
    			-user -xtype -exec -fls -fprint -fprint0 -fprintf -ok \
    			-print -print0 -printf -prune -ls' -- $cur ));
        onlyonce=' -daystart -depth -follow -help -maxdepth -mindepth -mount \
    		   -noleaf -version -xdev ';
        COMPREPLY=($( echo "${COMP_WORDS[@]}" | 		       (while read -d ' ' i; do
    			    [ "$i" == "" ] ||
    			    [ "${onlyonce/ ${i%% *} / }" == "$onlyonce" ] &&
    			    continue
    			    # flatten array with spaces on either side,
    			    # otherwise we cannot grep on word boundaries of
    			    # first and last word
    			    COMPREPLY=" ${COMPREPLY[@]} "
    			    # remove word from list of completions
    			    COMPREPLY=( ${COMPREPLY/ ${i%% *} / } )
    			done
    			echo "${COMPREPLY[@]}")
    		  ));
        _filedir;
        return 0
    }
    _function () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        if [[ $1 == @(declare|typeset) ]]; then
            if [ "$prev" = -f ]; then
                COMPREPLY=($( compgen -A function -- $cur ));
            else
                if [[ "$cur" == -* ]]; then
                    COMPREPLY=($( compgen -W '-a -f -F -i -r -x -p' -- 				       $cur ));
                fi;
            fi;
        else
            if [ $COMP_CWORD -eq 1 ]; then
                COMPREPLY=($( compgen -A function -- $cur ));
            else
                COMPREPLY=("() $( type -- ${COMP_WORDS[1]} | sed -e 1,2d )");
            fi;
        fi
    }
    _gcc () 
    { 
        local cur cc backend;
        COMPREPLY=();
        cur=`_get_cword`;
        _expand || return 0;
        case "$1" in 
            gcj)
                backend=jc1
            ;;
            gpc)
                backend=gpc1
            ;;
            *77)
                backend=f771
            ;;
            *)
                backend=cc1
            ;;
        esac;
        if [[ "$cur" == -* ]]; then
            cc=$( $1 -print-prog-name=$backend );
            COMPREPLY=($( $cc --help 2>/dev/null | tr '\t' ' ' | 			       sed -e '/^  *-/!d' -e 's/ *-\([^ ]*\).*/-\1/' | 			       command grep "^$cur" | sort -u ));
        else
            _filedir;
        fi
    }
    _gdb () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        if [ $COMP_CWORD -eq 1 ]; then
            COMPREPLY=($( compgen -c -- $cur ));
        else
            if [ $COMP_CWORD -eq 2 ]; then
                prev=${prev##*/};
                COMPREPLY=($( compgen -fW "$( command ps axo comm,pid | 				awk '{if ($1 ~ /^'"$prev"'/) print $2}' ) )" 				-- "$cur" ));
            fi;
        fi
    }
    _get_cword () 
    { 
        if [[ "${#COMP_WORDS[COMP_CWORD]}" -eq 0 ]] || [[ "$COMP_POINT" == "${#COMP_LINE}" ]]; then
            echo "${COMP_WORDS[COMP_CWORD]}";
        else
            local i;
            local cur="$COMP_LINE";
            local index="$COMP_POINT";
            for ((i = 0; i <= COMP_CWORD; ++i ))
            do
                while [[ "${#cur}" -ge ${#COMP_WORDS[i]} ]] && [[ "${cur:0:${#COMP_WORDS[i]}}" != "${COMP_WORDS[i]}" ]]; do
                    cur="${cur:1}";
                    index="$(( index - 1 ))";
                done;
                if [[ "$i" -lt "$COMP_CWORD" ]]; then
                    local old_size="${#cur}";
                    cur="${cur#${COMP_WORDS[i]}}";
                    local new_size="${#cur}";
                    index="$(( index - old_size + new_size ))";
                fi;
            done;
            if [[ "${COMP_WORDS[COMP_CWORD]:0:${#cur}}" != "$cur" ]]; then
                echo "${COMP_WORDS[COMP_CWORD]}";
            else
                echo "${cur:0:$index}";
            fi;
        fi
    }
    _getent () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case $prev in 
            passwd)
                COMPREPLY=($( compgen -u $cur  ));
                return 0
            ;;
            group)
                COMPREPLY=($( compgen -g $cur  ));
                return 0
            ;;
            services)
                COMPREPLY=($( compgen -s $cur  ));
                return 0
            ;;
            hosts)
                COMPREPLY=($( compgen -A hostname $cur  ));
                return 0
            ;;
            protocols)
                COMPREPLY=($( getent protocols | awk '{print $1}' | grep "^$cur" ));
                return 0
            ;;
            networks)
                COMPREPLY=($( getent networks | awk '{print $1}' | grep "^$cur" ));
                return 0
            ;;
        esac;
        if [ $COMP_CWORD -eq 1 ]; then
            COMPREPLY=($( compgen -W 'passwd group hosts services protocols networks' -- $cur ));
        fi
    }
    _gids () 
    { 
        if type getent >&/dev/null; then
            COMPREPLY=($( getent group | 			    awk -F: '{if ($3 ~ /^'$cur'/) print $3}' ));
        else
            if type perl >&/dev/null; then
                COMPREPLY=($( compgen -W '$( perl -e '"'"'while (($gid) = (getgrent)[2]) { print $gid . "\n" }'"'"' )' -- $cur ));
            else
                COMPREPLY=($( awk 'BEGIN {FS=":"} {if ($3 ~ /^'$cur'/) print $3}'			    /etc/group ));
            fi;
        fi
    }
    _gpg () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case "$prev" in 
            -@(s|-sign|-clearsign|-decrypt-files|-load-extension))
                _filedir;
                return 0
            ;;
            --@(export|@(?(l|nr|nrl)sign|edit)-key))
                COMPREPLY=($( compgen -W "$( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*/\([^ ]*\).*\(<\([^>]*\)>\).*$@\1 \3@p')" -- "$cur" ));
                return 0
            ;;
            -@(r|-recipient))
                COMPREPLY=($( compgen -W "$( gpg --list-keys 2>/dev/null | sed -ne 's@^pub.*<\([^>]*\)>.*$@\1@p')" -- "$cur" ));
                if [ -e ~/.gnupg/gpg.conf ]; then
                    COMPREPLY=("${COMPREPLY[@]}" $( compgen -W "$( sed -ne 's@^[ \t]*group[ \t][ \t]*\([^=]*\).*$@\1@p' ~/.gnupg/gpg.conf  )" -- "$cur"));
                fi;
                return 0
            ;;
        esac;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-s -b -e -f -c -d -a -r -u -Z -o -v\
    				-q -n -N $(gpg --dump-options)' -- $cur ));
        fi
    }
    _gzip () 
    { 
        local cur prev xspec IFS='	
    ';
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-c -d -f \
    			-h -l -L -n -N -q -r -S -t -v -V \
    			-1 -2 -3 -4 -5 -6 -7 -8 -9 \
    			--stdout --decompress --force --help --list \
    			--license --no-name --name --quiet --recursive \
    			--suffix --test --verbose --version --fast \
    			--best' -- $cur ));
            return 0;
        fi;
        xspec="*.?(t)gz";
        if [[ "$prev" == --* ]]; then
            [[ "$prev" == --decompress || "$prev" == --list || "$prev" == --test ]] && xspec="!"$xspec;
            [[ "$prev" == --force ]] && xspec=;
        else
            if [[ "$prev" == -* ]]; then
                [[ "$prev" == -*[dlt]* ]] && xspec="!"$xspec;
                [[ "$prev" == -*f* ]] && xspec=;
            else
                if [ "$prev" = '>' ]; then
                    xspec=;
                else
                    if [ "$prev" = '<' ]; then
                        xspec=;
                    fi;
                fi;
            fi;
        fi;
        _expand || return 0;
        COMPREPLY=($( compgen -f -X "$xspec" -- $cur ) $( compgen -d -- $cur ))
    }
    _iconv () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case "$prev" in 
            -@(f|t|-@(from|to)-code))
                COMPREPLY=($( compgen -W 			    '$( iconv --list | sed -e "s@//@@;" )' -- "$cur" ));
                return 0
            ;;
        esac;
        if [[ "$cur" = -* ]]; then
            COMPREPLY=($( compgen -W '--from-code -f --to-code -t --list
    		--output -o --verbose' -- "$cur" ));
            return 0;
        fi
    }
    _id () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-a -g --group -G --groups -n --name\
    			-r --real -u --user --help --version' -- $cur ));
        else
            COMPREPLY=($( compgen -u $cur  ));
        fi
    }
    _ifupdown () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        if [ $COMP_CWORD -eq 1 ]; then
            _configured_interfaces;
            COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur"));
        fi;
        return 0
    }
    _info () 
    { 
        local cur infopath UNAME;
        COMPREPLY=();
        cur=`_get_cword`;
        _expand || return 0;
        if [[ "$cur" == */* ]]; then
            _filedir;
            return 0;
        fi;
        infopath='/usr/share/info';
        if [ "${INFOPATH: -1:1}" == ':' ]; then
            infopath=${INFOPATH}${infopath};
        else
            if [ ${INFOPATH:+set} ]; then
                infopath=$INFOPATH;
            fi;
        fi;
        infopath=$infopath:;
        if [ -n "$cur" ]; then
            infopath="${infopath//://$cur* }";
        else
            infopath="${infopath//:// }";
        fi;
        COMPREPLY=($( eval command ls "$infopath" 2>/dev/null ));
        COMPREPLY=(${COMPREPLY[@]##*/?(:)});
        for ((i=0 ; i < ${#COMPREPLY[@]} ; ++i ))
        do
            if [ "${COMPREPLY[$i]}" == 'dir' ]; then
                unset COMPREPLY[$i];
            fi;
        done;
        COMPREPLY=(${COMPREPLY[@]%.@(gz|bz2)});
        COMPREPLY=($( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ));
        return 0
    }
    _insmod () 
    { 
        local cur prev modpath;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        if [ $1 = "modprobe" ] && [ "${COMP_WORDS[1]}" = "-r" ]; then
            COMPREPLY=($( /sbin/lsmod | 				awk '{if (NR != 1 && $1 ~ /^'$cur'/) print $1}' ));
            return 0;
        fi;
        if [[ "$cur" == */* ]]; then
            _filedir '@(?(k)o?(.gz))';
            return 0;
        fi;
        if [ $COMP_CWORD -gt 1 ] && [[ "${COMP_WORDS[COMP_CWORD-1]}" != -* ]]; then
            COMPREPLY=($( /sbin/modinfo -p ${COMP_WORDS[1]} 2>/dev/null | 		       awk '{if ($1 ~ /^parm:/ && $2 ~ /^'$cur'/) { print $2 } \
    			else if ($1 !~ /:/ && $1 ~ /^'$cur'/) { print $1 }}' ));
        else
            _modules $(uname -r);
        fi;
        return 0
    }
    _invoke_rc_d () 
    { 
        local cur prev sysvdir services options valid_options;
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d;
        services=($(echo $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm*)));
        services=(${services[@]#$sysvdir/});
        options=(--help --quiet --force --try-anyway --disclose-deny --query --no-fallback);
        if [[ ( $COMP_CWORD -eq 1 ) || ( "$prev" == --* ) ]]; then
            valid_options=($( 	    echo ${COMP_WORDS[@]} ${options[@]} 	    | tr " " "\n" 	    | sed -ne "/$( echo ${options[@]} | sed "s/ /\\\\|/g" )/p" 	    | sort | uniq -u 	    ));
            COMPREPLY=($( compgen -W '${valid_options[@]} ${services[@]}' -- 	    $cur ));
        else
            if [ -x $sysvdir/$prev ]; then
                COMPREPLY=($( compgen -W '`sed -ne "y/|/ /; \
    					    s/^.*Usage:[ ]*[^ ]*[ ]*{*\([^}\"]*\).*$/\1/p" \
    					    $sysvdir/$prev`' -- 	    $cur ));
            else
                COMPREPLY=();
            fi;
        fi;
        return 0
    }
    _iptables () 
    { 
        local cur prev table chain;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        chain='s/^Chain \([^ ]\+\).*$/\1/p';
        if [[ $COMP_LINE == *-t\ *filter* ]]; then
            table="-t filter";
        else
            if [[ $COMP_LINE == *-t\ *nat* ]]; then
                table="-t nat";
            else
                if [[ $COMP_LINE == *-t\ *mangle* ]]; then
                    table="-t mangle";
                fi;
            fi;
        fi;
        case "$prev" in 
            -*[AIDRPFXLZ])
                COMPREPLY=($( compgen -W '`iptables $table -nL | \
    			    sed -ne "s/^Chain \([^ ]\+\).*$/\1/p"`' -- $cur ))
            ;;
            -*t)
                COMPREPLY=($( compgen -W 'nat filter mangle' -- $cur ))
            ;;
            -j)
                if [ "$table" = "-t filter" -o "$table" = "" ]; then
                    COMPREPLY=($( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
    		    `iptables $table -nL | sed -ne "$chain" \
    		    -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- 		    $cur ));
                else
                    if [ "$table" = "-t nat" ]; then
                        COMPREPLY=($( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
    		    MIRROR SNAT DNAT MASQUERADE `iptables $table -nL | \
    		    sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' 		    -- $cur ));
                    else
                        if [ "$table" = "-t mangle" ]; then
                            COMPREPLY=($( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
    		    MARK TOS `iptables $table -nL | sed -ne "$chain" \
    		    -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- 		    $cur ));
                        fi;
                    fi;
                fi
            ;;
            *)
                if [[ "$cur" == -* ]]; then
                    COMPREPLY=($( compgen -W '-i -o -s -d -p -f -m --append \
    		    --delete --insert --replace --list --flush --zero --new \
    		    --delete-chain --policy --rename-chain --proto --source \
    		    --destination --in-interface --jump --match --numeric \
    		    --out-interface --table --verbose --line-numbers --exact \
    		    --fragment --modprobe= --set-counters --version' -- "$cur"));
                fi
            ;;
        esac
    }
    _iwconfig () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case $prev in 
            mode)
                COMPREPLY=($( compgen -W 'managed ad-hoc master \
    				repeater secondary monitor' -- $cur ));
                return 0
            ;;
            essid)
                COMPREPLY=($( compgen -W 'on off any' -- $cur ));
                if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
                    COMPREPLY=("${COMPREPLY[@]}" $( iwlist ${COMP_WORDS[1]} scan | 					awk -F '"' '/ESSID/ {print $2}' | 					grep "^$cur" ));
                fi;
                return 0
            ;;
            nwid)
                COMPREPLY=($( compgen -W 'on off' -- $cur ));
                return 0
            ;;
            channel)
                COMPREPLY=($( iwlist ${COMP_WORDS[1]} channel | 				awk '/^[[:space:]]*Channel/ {print $2}' | 				grep "^$cur" ));
                return 0
            ;;
            freq)
                COMPREPLY=($( iwlist ${COMP_WORDS[1]} channel | 				awk '/^[[:space:]]*Channel/ {print $4"G"}' | 				grep "^$cur" ));
                return 0
            ;;
            ap)
                COMPREPLY=($( compgen -W 'on off any' -- $cur ));
                if [ -n "${COMP_IWLIST_SCAN:-}" ]; then
                    COMPREPLY=("${COMPREPLY[@]}" $( iwlist ${COMP_WORDS[1]} scan | 					awk -F ': ' '/Address/ {print $2}' | 					grep "^$cur" ));
                fi;
                return 0
            ;;
            rate)
                COMPREPLY=($( compgen -W 'auto fixed' -- $cur ));
                COMPREPLY=("${COMPREPLY[@]}" $( iwlist ${COMP_WORDS[1]} rate | 				awk '/^[[:space:]]*[0-9]/ {print $1"M"}' | 				grep "^$cur" ));
                return 0
            ;;
            rts)
                COMPREPLY=($( compgen -W 'auto fixed off' -- $cur ));
                return 0
            ;;
            frag)
                COMPREPLY=($( compgen -W 'auto fixed off' -- $cur ));
                return 0
            ;;
            key)
                COMPREPLY=($( compgen -W 'off on open restricted' -- $cur ));
                return 0
            ;;
            enc)
                COMPREPLY=($( compgen -W 'off on open restricted' -- $cur ));
                return 0
            ;;
            power)
                COMPREPLY=($( compgen -W 'period timeout off on' -- $cur ));
                return 0
            ;;
            txpower)
                COMPREPLY=($( compgen -W 'off on auto' -- $cur ));
                return 0
            ;;
            retry)
                COMPREPLY=($( compgen -W 'limit lifetime' -- $cur ));
                return 0
            ;;
        esac;
        if [ $COMP_CWORD -eq 1 ]; then
            if [[ "$cur" == -* ]]; then
                COMPREPLY=($( compgen -W '--help --version' -- $cur ));
            else
                _available_interfaces -w;
            fi;
        else
            COMPREPLY=($( compgen -W 'essid nwid mode freq channel sens mode \
    			ap nick rate rts frag enc key power txpower commit' -- $cur ));
        fi
    }
    _iwlist () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        if [ $COMP_CWORD -eq 1 ]; then
            if [[ "$cur" == -* ]]; then
                COMPREPLY=($( compgen -W '--help --version' -- $cur ));
            else
                _available_interfaces -w;
            fi;
        else
            COMPREPLY=($( compgen -W 'scan scanning freq frequency \
    			channel rate bit bitrate key enc encryption power \
    			txpower retry ap accesspoint peers event' -- $cur ));
        fi
    }
    _iwpriv () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case "$prev" in 
            roam)
                COMPREPLY=($( compgen -W 'on off' -- $cur ));
                return 0
            ;;
            port)
                COMPREPLY=($( compgen -W 'ad-hoc managed' -- $cur ));
                return 0
            ;;
        esac;
        if [ $COMP_CWORD -eq 1 ]; then
            if [[ "$cur" == -* ]]; then
                COMPREPLY=($( compgen -W '--help --version' -- $cur ));
            else
                _available_interfaces -w;
            fi;
        else
            COMPREPLY=($( compgen -W '--all roam port' -- $cur ));
        fi
    }
    _iwspy () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        if [ $COMP_CWORD -eq 1 ]; then
            if [[ "$cur" == -* ]]; then
                COMPREPLY=($( compgen -W '--help --version' -- $cur ));
            else
                _available_interfaces -w;
            fi;
        else
            COMPREPLY=($( compgen -W 'setthr getthr off' -- $cur ));
        fi
    }
    _jar () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        if [ $COMP_CWORD = 1 ]; then
            COMPREPLY=($( compgen -W 'c t x u' -- $cur ));
            return 0;
        fi;
        case "${COMP_WORDS[1]}" in 
            *c*f)
                _filedir
            ;;
            *f)
                _filedir '?(e|j|w)ar'
            ;;
            *)
                _filedir
            ;;
        esac
    }
    _java () 
    { 
        local cur prev i;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        for ((i=1; i < $COMP_CWORD; i++))
        do
            case ${COMP_WORDS[$i]} in 
                -cp | -classpath)
                    ((i++))
                ;;
                -*)
    
                ;;
                *)
                    _filedir;
                    return 0
                ;;
            esac;
        done;
        case $prev in 
            -@(cp|classpath))
                _java_path;
                return 0
            ;;
        esac;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-client -hotspot -server -classic \
    				-cp -classpath -D -verbose -verbose:class \
    				-verbose:gc -version:jni -version \
    				-showversion -? -help -X -jar \
    				-ea -enableassertions -da -disableassertions \
    				-esa -enablesystemassertions \
    				-dsa -disablesystemassertions ' -- $cur ));
        else
            if [[ "$prev" == -jar ]]; then
                _filedir jar;
            else
                _java_classes;
            fi;
        fi
    }
    _java_classes () 
    { 
        local classpath i;
        _java_find_classpath;
        cur=${cur//.//};
        for i in ${classpath//:/ };
        do
            if [ -r $i ] && [[ "$i" == *.@(jar|zip) ]]; then
                if type zipinfo >&/dev/null; then
                    COMPREPLY=("${COMPREPLY[@]}" $( zipinfo -1 				"$i" | grep "^$cur" | grep '\.class$' | 				grep -v "\\$" ));
                else
                    COMPREPLY=("${COMPREPLY[@]}" $( jar tf "$i" 				"$cur" | grep "\.class$" | grep -v "\\$" ));
                fi;
            else
                if [ -d $i ]; then
                    i=${i%/};
                    COMPREPLY=("${COMPREPLY[@]}" $( find "$i" -type f 			-path "$i/$cur*.class" 2>/dev/null | 			grep -v "\\$" | sed -e "s|^$i/||" ));
                fi;
            fi;
        done;
        COMPREPLY=(${COMPREPLY[@]%.class});
        COMPREPLY=(${COMPREPLY[@]//\//.})
    }
    _java_find_classpath () 
    { 
        local i;
        for ((i=1; i < COMP_CWORD; i++ ))
        do
            if [[ "${COMP_WORDS[i]}" == -@(cp|classpath) ]]; then
                classpath=${COMP_WORDS[i+1]};
                break;
            fi;
        done;
        [ -z "$classpath" ] && classpath=$CLASSPATH;
        [ -z "$classpath" ] && classpath=.
    }
    _java_find_sourcepath () 
    { 
        local i;
        for ((i=1; i < COMP_CWORD; i++ ))
        do
            if [[ "${COMP_WORDS[i]}" == -sourcepath ]]; then
                sourcepath=${COMP_WORDS[i+1]};
                break;
            fi;
        done;
        [ -z "$sourcepath" ] && _java_find_classpath;
        sourcepath=$classpath
    }
    _java_packages () 
    { 
        local sourcepath i;
        _java_find_sourcepath;
        cur=${cur//.//};
        for i in ${sourcepath//:/ };
        do
            if [ -d $i ]; then
                COMPREPLY=("${COMPREPLY[@]}" $( command ls -F -d 				$i/$cur* 2>/dev/null | sed -e 's|^'$i'/||' ));
            fi;
        done;
        COMPREPLY=($( echo "${COMPREPLY[@]}" | tr " " "\n" | grep "/$" ));
        COMPREPLY=(${COMPREPLY[@]%/});
        cur=${COMPREPLY[@]//\//.}
    }
    _java_path () 
    { 
        cur=${cur##*:};
        _filedir '@(jar|zip)'
    }
    _javac () 
    { 
        COMPREPLY=();
        local cur prev;
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case $prev in 
            -d)
                _filedir -d;
                return 0
            ;;
            -@(classpath|bootclasspath|sourcepath|extdirs))
                _java_path;
                return 0
            ;;
        esac;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-g -g:none -g:lines -g:vars\
    		-g:source -O -nowarn -verbose -deprecation -classpath\
    		-sourcepath -bootclasspath -extdirs -d -encoding -source\
    		-target -help' -- $cur ));
        else
            _filedir java;
        fi
    }
    _javadoc () 
    { 
        COMPREPLY=();
        local cur prev;
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case $prev in 
            -@(overview|helpfile|stylesheetfile))
                _filedir;
                return 0
            ;;
            -d)
                _filedir -d;
                return 0
            ;;
            -@(classpath|bootclasspath|docletpath|sourcepath|extdirs))
                _java_path;
                return 0
            ;;
        esac;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-overview -public -protected \
    				-package -private -help -doclet -docletpath \
    				-sourcepath -classpath -exclude -subpackages \
    				-breakiterator -bootclasspath -source -extdirs \
    				-verbose -locale -encoding -J -d -use -version \
    				-author -docfilessubdirs -splitindex \
    				-windowtitle -doctitle -header -footer -bottom \
    				-link -linkoffline -excludedocfilessubdir \
    				-group -nocomment -nodeprecated -noqualifier \
    				-nosince -nodeprecatedlist -notree -noindex \
    				-nohelp -nonavbar -quiet -serialwarn -tag \
    				-taglet -tagletpath -charset -helpfile \
    				-linksource -stylesheetfile -docencoding' -- 				$cur ));
        else
            _filedir java;
            _java_packages;
        fi
    }
    _kernels () 
    { 
        COMPREPLY=($( command ls /lib/modules | grep "^$cur" ))
    }
    _kill () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then
            _signals;
        else
            _pids;
        fi
    }
    _killall () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        if [ $COMP_CWORD -eq 1 ] && [[ "$cur" == -* ]]; then
            _signals;
        else
            COMPREPLY=($( compgen -W '$( command ps axo command | \
    			      sed -ne "1d; s/^\[\?\([^-][^] ]*\).*$/\1/p" | \
    			      sed -e "s/.*\///" )' -- $cur ));
        fi;
        return 0
    }
    _known_hosts () 
    { 
        local cur curd ocur user suffix aliases global_kh user_kh hosts i host;
        local -a kh khd config;
        COMPREPLY=();
        cur=`_get_cword`;
        ocur=$cur;
        [ "$1" = -a ] || [ "$2" = -a ] && aliases='yes';
        [ "$1" = -c ] || [ "$2" = -c ] && suffix=':';
        [[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@};
        kh=();
        [ -r /etc/ssh/ssh_config ] && config=("${config[@]}" "/etc/ssh/ssh_config");
        [ -r "${HOME}/.ssh/config" ] && config=("${config[@]}" "${HOME}/.ssh/config");
        [ -r "${HOME}/.ssh2/config" ] && config=("${config[@]}" "${HOME}/.ssh2/config");
        if [ ${#config[@]} -gt 0 ]; then
            global_kh=$( eval echo $( sed -ne 's/^[ \t]*[Gg][Ll][Oo][Bb][Aa][Ll][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/\1/p' "${config[@]}" ) );
            user_kh=$( eval echo $( sed -ne 's/^[ \t]*[Uu][Ss][Ee][Rr][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/\1/p' "${config[@]}" ) );
        fi;
        [ -r "$global_kh" ] && kh=("${kh[@]}" "$global_kh");
        [ -r /etc/ssh/ssh_known_hosts ] && kh=("${kh[@]}" /etc/ssh/ssh_known_hosts);
        [ -r /etc/ssh/ssh_known_hosts2 ] && kh=("${kh[@]}" /etc/ssh/ssh_known_hosts2);
        [ -r /etc/known_hosts ] && kh=("${kh[@]}" /etc/known_hosts);
        [ -r /etc/known_hosts2 ] && kh=("${kh[@]}" /etc/known_hosts2);
        [ -d /etc/ssh2/knownhosts ] && khd=("${khd[@]}" /etc/ssh2/knownhosts/*pub);
        [ -r "$user_kh" ] && kh=("${kh[@]}" "$user_kh");
        [ -r ~/.ssh/known_hosts ] && kh=("${kh[@]}" ~/.ssh/known_hosts);
        [ -r ~/.ssh/known_hosts2 ] && kh=("${kh[@]}" ~/.ssh/known_hosts2);
        [ -d ~/.ssh2/hostkeys ] && khd=("${khd[@]}" ~/.ssh2/hostkeys/*pub);
        if [ ${#kh[@]} -gt 0 -o ${#khd[@]} -gt 0 ]; then
            cur=${cur//\//\\\/};
            cur=${cur//\./\\\.};
            curd=$cur;
            if [[ "$cur" == [0-9]*.* ]]; then
                cur="^$cur.*";
            else
                if [[ "$cur" == [0-9]* ]]; then
                    cur="^$cur.*\.";
                else
                    if [ -z "$cur" ]; then
                        cur="[a-z.]";
                    else
                        cur="^$cur";
                    fi;
                fi;
            fi;
            if [ ${#kh[@]} -gt 0 ]; then
                COMPREPLY=($( awk 'BEGIN {FS=","}
    				/^[^|]/ {for (i=1; i<=2; ++i) { \
    				       gsub(" .*$", "", $i); \
    				       if ($i ~ /'$cur'/) {print $i} \
    				}}' "${kh[@]}" 2>/dev/null ));
            fi;
            if [ ${#khd[@]} -gt 0 ]; then
                for i in "${khd[@]}";
                do
                    if [[ "$i" == *key_22_$curd*.pub ]] && [ -r "$i" ]; then
                        host=${i/#*key_22_/};
                        host=${host/%.pub/};
                        COMPREPLY=("${COMPREPLY[@]}" $host);
                    fi;
                done;
            fi;
            if [ ${#config[@]} -gt 0 ] && [ -n "$aliases" ]; then
                local host_aliases=$( sed -ne 's/^[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\?['"$'\t '"']\+\([^*?]*\)$/\2/p' "${config[@]}" );
                hosts=$( compgen -W "$host_aliases" -- $ocur );
                COMPREPLY=("${COMPREPLY[@]}" $hosts);
            fi;
            COMPREPLY=("${COMPREPLY[@]}" $( compgen -A hostname -- $ocur ));
            for ((i=0; i < ${#COMPREPLY[@]}; i++ ))
            do
                COMPREPLY[i]=$user${COMPREPLY[i]}$suffix;
            done;
        else
            COMPREPLY=($( compgen -A hostname -S "$suffix" -- $cur ));
        fi;
        return 0
    }
    _lftp () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        if [ $COMP_CWORD -eq 1 ] && [ -f ~/.lftp/bookmarks ]; then
            COMPREPLY=($( compgen -W '$( sed -ne "s/^\(.*\)''	''.*$/\1/p" \
    			   ~/.lftp/bookmarks )' -- $cur ));
        fi;
        return 0
    }
    _lilo () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case $prev in 
            -@(C|i|m|s|S))
                _filedir;
                return 0
            ;;
            -r)
                _filedir -d;
                return 0
            ;;
            -@(I|D|R))
                _lilo_labels;
                return 0
            ;;
            -@(A|b|M|u|U))
                cur=${cur:=/dev/};
                _filedir;
                return 0
            ;;
            -T)
                COMPREPLY=($( compgen -W 'help ChRul EBDA geom geom= \
    					table= video' -- $cur ));
                return 0
            ;;
        esac;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-A -b -c -C -d -f -g -i -I -l -L -m \
    			-M -p -P -q -r -R -s -S -t -T -u -U -v -V -w -x -z' -- 			$cur ));
        fi
    }
    _lilo_labels () 
    { 
        COMPREPLY=($( awk -F'=' '/label/ {print $2}' 		/etc/lilo.conf | sed -e 's/"//g' | grep "^$cur" ))
    }
    _longopt () 
    { 
        local cur opt;
        cur=`_get_cword`;
        if [[ "$cur" == --*=* ]]; then
            opt=${cur%%=*};
            opt=${opt%\\*};
            cur=${cur#*=};
            _filedir;
            COMPREPLY=($( compgen -P "$opt=" -W '${COMPREPLY[@]}' -- $cur));
            return 0;
        fi;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( $1 --help 2>&1 | sed -e '/--/!d' 				-e 's/.*\(--[-A-Za-z0-9]\+=\?\).*/\1/' | 			       command grep "^$cur" | sort -u ));
        else
            if [[ "$1" == @(mk|rm)dir ]]; then
                _filedir -d;
            else
                _filedir;
            fi;
        fi
    }
    _look () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        if [ $COMP_CWORD = 1 ]; then
            COMPREPLY=($( compgen -W '$(look $cur)' ));
        fi
    }
    _make () 
    { 
        local file makef makef_dir="." makef_inc cur prev i;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case $prev in 
            -@(f|o|W))
                _filedir;
                return 0
            ;;
            -@(I|C))
                _filedir -d;
                return 0
            ;;
        esac;
        if [[ "$cur" == *=* ]]; then
            prev=${cur/=*/};
            cur=${cur/*=/};
            case "$prev" in 
                --@(file|makefile))
                    _filedir;
                    return 0
                ;;
                --@(directory|include-dir))
                    _filedir -d;
                    return 0
                ;;
            esac;
        fi;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-b -m -B -C -d -e -f -h -i -I\
    			-j -l -k -n -o -p -q -r -R - s -S -t -v -w -W \
    			--always-make --directory= --debug \
    			--environment-overrides --file= --makefile= --help \
    			--ignore-errors --include-dir= --jobs --load-average \
    			--max-load --keep-going --just-print --dry-run \
    			--recon --old-file= --assume-old= --print-data-base \
    			--question --no-builtin-rules --no-builtin-variables \
    			--silent --quiet --no-keep-goind --stop --touch \
    			--version --print-directory --no-print-directory \
    			--what-if= --new-file= --assume-new= \
    			--warn-undefined-variables' -- $cur ));
        else
            for ((i=0; i < ${#COMP_WORDS[@]}; i++ ))
            do
                if [[ ${COMP_WORDS[i]} == -C ]]; then
                    eval makef_dir=${COMP_WORDS[i+1]};
                    break;
                fi;
            done;
            if [ -f ${makef_dir}/GNUmakefile ]; then
                makef=${makef_dir}/GNUmakefile;
            else
                if [ -f ${makef_dir}/makefile ]; then
                    makef=${makef_dir}/makefile;
                else
                    if [ -f ${makef_dir}/Makefile ]; then
                        makef=${makef_dir}/Makefile;
                    else
                        makef=${makef_dir}/*.mk;
                    fi;
                fi;
            fi;
            for ((i=0; i < ${#COMP_WORDS[@]}; i++ ))
            do
                if [[ ${COMP_WORDS[i]} == -f ]]; then
                    eval makef=${COMP_WORDS[i+1]};
                    break;
                fi;
            done;
            [ ! -f $makef ] && return 0;
            makef_inc=$( grep -E '^-?include' $makef | sed -e "s,^.* ,"$makef_dir"/," );
            for file in $makef_inc;
            do
                [ -f $file ] && makef="$makef $file";
            done;
            COMPREPLY=($( awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ \
    				{split($1,A,/ /);for(i in A)print A[i]}' 				$makef 2>/dev/null | command grep "^$cur" ));
        fi
    }
    _man () 
    { 
        local cur prev sect manpath UNAME;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        _expand || return 0;
        if [[ "$cur" == */* ]]; then
            _filedir;
            return 0;
        fi;
        UNAME=$( uname -s );
        UNAME=${UNAME/CYGWIN_*/Cygwin};
        if [ $UNAME = GNU -o $UNAME = Linux -o $UNAME = FreeBSD -o $UNAME = Cygwin ]; then
            manpath=$( manpath 2>/dev/null || command man --path );
        else
            manpath=$MANPATH;
        fi;
        if [ -z "$manpath" ]; then
            COMPREPLY=($( compgen -c -- $cur ));
            return 0;
        fi;
        [[ "$prev" == [0-9ln] ]] && sect=$prev || sect='*';
        manpath=$manpath:;
        if [ -n "$cur" ]; then
            manpath="${manpath//://*man$sect/$cur* } ${manpath//://*cat$sect/$cur* }";
        else
            manpath="${manpath//://*man$sect/ } ${manpath//://*cat$sect/ }";
        fi;
        COMPREPLY=($( eval command ls "$manpath" 2>/dev/null ));
        COMPREPLY=(${COMPREPLY[@]##*/?(:)});
        COMPREPLY=(${COMPREPLY[@]%.@(gz|bz2)});
        COMPREPLY=($( compgen -W '${COMPREPLY[@]%.*}' -- "${cur//\\\\/}" ));
        [[ "$prev" != [0-9ln] ]] && _filedir '[0-9ln]';
        return 0
    }
    _mkisofs () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case "$prev" in 
            -@(o|abstract|biblio|check-session|copyright|log-file|root-info|prep-boot|*-list))
                _filedir;
                return 0
            ;;
            -*-charset)
                COMPREPLY=($( mkisofs -input-charset help 2>&1 | 					tail +3 | grep "^$cur"));
                return 0
            ;;
            -uid)
                _uids;
                return 0
            ;;
            -gid)
                _gids;
                return 0
            ;;
        esac;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-abstract -A -allow-lowercase \
    				-allow-multidot -biblio -cache-inodes \
    				-no-cache-inodes -b -eltorito-alt-boot -B -G \
    				-hard-disk-boot -no-emul-boot -no-boot \
    				-boot-load-seg -boot-load-size \
    				-boot-info-table -C -c -check-oldname \
    				-check-session -copyright -d -D -dir-mode \
    				-dvd-video -f -file-mode -gid -gui \
    				-graft-points -hide -hide-list -hidden \
    				-hidden-list -hide-joliet -hide-joliet-list \
    				-hide-joliet-trans-tbl -hide-rr-moved \
    				-input-charset -output-charset -iso-level -J \
    				-joliet-long -jcharset -l -L -log-file -m \
    				-exclude-list -max-iso9660-filenames -M -N \
    				-new-dir-mode -nobak -no-bak -force-rr -no-rr \
    				-no-split-symlink-components \
    				-no-split-symlink-fields -o -pad -no-pad \
    				-path-list -P -p -print-size -quiet -R -r \
    				-relaxed-filenames -sort -split-output \
    				-stream-media-size -stream-file-name -sysid -T\
    				-table-name -ucs-level -udf -uid \
    				-use-fileversion -U -no-iso-translate -V \
    				-volset -volset-size -volset-seqno -v -x -z \
    				-hfs -apple -map -magic -hfs-creator \
    				-hfs-type -probe -no-desktop -mac-name \
    				-boot-hfs-file -part -auto -cluster-size \
    				-hide-hfs -hide-hfs-list -hfs-volid \
    				-icon-position -root-info -prep-boot \
    				-input-hfs-charset -output-hfs-charset \
    				-hfs-unlock -hfs-bless -hfs-parms --cap \
    				--netatalk --double --ethershare --ushare \
    				--exchange --sgi --xinet --macbin --single \
    				--dave --sfm --osx-double --osx-hfs' -- $cur ));
        else
            _filedir;
        fi
    }
    _modules () 
    { 
        local modpath;
        modpath=/lib/modules/$1;
        COMPREPLY=($( command ls -R $modpath | 			sed -ne 's/^\('$cur'.*\)\.k\?o\(\|.gz\)$/\1/p'))
    }
    _mount () 
    { 
        local cur i sm host;
        COMPREPLY=();
        cur=`_get_cword`;
        [[ "$cur" == \\ ]] && cur="/";
        for i in {,/usr}/{,s}bin/showmount;
        do
            [ -x $i ] && sm=$i && break;
        done;
        if [ -n "$sm" ] && [[ "$cur" == *:* ]]; then
            COMPREPLY=($( $sm -e ${cur%%:*} | sed 1d | 			       grep ^${cur#*:} | awk '{print $1}' ));
        else
            if [[ "$cur" == //* ]]; then
                host=${cur#//};
                host=${host%%/*};
                if [ -n "$host" ]; then
                    COMPREPLY=($( compgen -W "$( echo $( smbclient -d 0 -NL $host 2>/dev/null|
    			sed -ne '/^['"$'\t '"']*Sharename/,/^$/p' |
    			sed -ne '3,$s|^[^A-Za-z]*\([^'"$'\t '"']*\).*$|//'$host'/\1|p' ) )" -- "$cur" ));
                fi;
            else
                if [ -r /etc/vfstab ]; then
                    COMPREPLY=($( awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' 				/etc/vfstab | grep "^$cur" ));
                else
                    if [ ! -e /etc/fstab ]; then
                        COMPREPLY=($( mount | awk '! /^[ \t]*#/ {if ($3 ~ /\//) print $3}' 				 | grep "^$cur" ));
                    else
                        COMPREPLY=($( awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' 				/etc/fstab | grep "^$cur" ));
                    fi;
                fi;
            fi;
        fi;
        return 0
    }
    _mplayer () 
    { 
        local cmd cur prev skinsdir IFS=' 	
    ' i j k=0;
        COMPREPLY=();
        cmd=${COMP_WORDS[0]};
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case "$prev" in 
            -@(ac|afm|vc|vfm|ao|vo|vop|fstype))
                _mplayer_options_list mplayer $prev;
                return 0
            ;;
            -@(oac|ovc|of))
                _mplayer_options_list mencoder $prev;
                return 0
            ;;
            -audiofile)
                _filedir '@(mp3|MP3|mpg|MPG|ogg|OGG|wav|WAV|mid|MID|flac|FLAC|mka|MKA)';
                return 0
            ;;
            -font)
                _filedir '@(desc|ttf)';
                return 0
            ;;
            -sub)
                _filedir '@(srt|SRT|sub|SUB|txt|TXT|utf|UTF|rar|RAR|mpsub|smi|js|ssa|SSA|aas|AAS)';
                return 0
            ;;
            -vobsub)
                _filedir '@(idx|IDX|ifo|IFO|sub|SUB)';
                IFS='	
    ';
                COMPREPLY=($( for i in "${COMPREPLY[@]}"; do
    						if [ -f $i -a -r $i ]; then
    							echo ${i%.*}
    						else
    							echo $i
    						fi
    				       done ));
                IFS=' 	
    ';
                return 0
            ;;
            -ifo)
                _filedir '@(ifo|IFO)';
                return 0
            ;;
            -cuefile)
                _filedir '@(bin|BIN|cue|CUE)';
                return 0
            ;;
            -skin)
                if [ -n "$MPLAYER_SKINS_DIR" ]; then
                    skinsdir=$MPLAYER_SKINS_DIR;
                else
                    skinsdir=/usr/local/share/mplayer/Skin;
                fi;
                IFS='	
    ';
                for i in ~/.mplayer/Skin $skinsdir;
                do
                    if [ -d $i -a -r $i ]; then
                        for j in $( compgen -d $i/$cur );
                        do
                            COMPREPLY[$k]=${j#$i/};
                            k=$((++k));
                        done;
                    fi;
                done;
                IFS=' 	
    ';
                return 0
            ;;
            -@(mixer|@(cdrom|dvd)-device|dvdauth|fb|zrdev))
                cur=${cur:=/dev/};
                _filedir;
                return 0
            ;;
            -@(edl?(out)|lircconf|menu-cfg|playlist|csslib|dumpfile) | -@(subfile|vobsub|aofile|fbmodeconfig|include|o|dvdkey) | -passlogfile)
                _filedir;
                return 0
            ;;
            -@(auto@(q|sync)|loop|menu-root|speed|sstep|aid|alang) | -@(?(@(audio|sub)-)demuxer|bandwidth|cache|chapter) | -@(dvd?(angle)|fps|frames|mc|passwd|user|sb|srate|ss|vcd) | -@(vi?(d|vo)|ffactor|sid|slang|spu@(align|aa|gauss)) | -@(vobsubid|delay|bpp|brightness|contrast|dfbopts|display) | -@(fbmode|geometry|guiwid|hue|icelayer|screen[wh]|wid) | -@(monitor@(aspect|-@(dotclock|[hv]freq))|panscan|saturation) | -@(xineramascreen|zr@(crop|norm|quality|[xy]doff|[vh]dec)) | -@(aspect|pp|x|y|xy|z|stereo|audio-@(density|delay|preload)) | -@(endpos|osdlevel|ffourcc|sws|channels|skiplimit|format) | -@(ofps|aa@(driver|@(osd|sub)color)|vobsubout?(i@(ndex|d))) | -sub@(-bg-@(alpha|color)|cp|delay|fps|pos|align|width) | -sub@(font-@(blur|outline|autoscale|encoding|@(osd|text)-scale)))
                return 0
            ;;
            -lavdopts)
                COMPREPLY=($( compgen -W 'ec er= bug= idct= gray' 					-- $cur ));
                return 0
            ;;
            -lavcopts)
                COMPREPLY=($( compgen -W 'vcodec= vqmin= vqscale= \
    					vqmax= mbqmin= mbqmax= vqdiff= \
    					vmax_b_frames= vme= vhq v4mv \
    					keyint= vb_strategy= vpass= \
    					aspect= vbitrate= vratetol= \
    					vrc_maxrate= vrc_minrate= \
    					vrc_buf_size= vb_qfactor= vi_qfactor= \
    					vb_qoffset= vi_qoffset= vqblur= \
    					vqcomp= vrc_eq= vrc_override= \
    					vrc_init_cplx= vqsquish= vlelim= \
    					vcelim= vstrict= vdpart vpsize= gray \
    					vfdct= idct= lumi_mask= dark_mask= \
    					tcplx_mask= scplx_mask= naq ildct \
    					format= pred qpel precmp= cmp= \
    					subcmp= predia= dia= trell last_pred= \
    					preme= subq= psnr mpeg_quant aic umv' 					-- $cur ));
                return 0
            ;;
            -ssf)
                COMPREPLY=($( compgen -W 'lgb= cgb= ls= cs= chs= \
    					cvs=' -- $cur ));
                return 0
            ;;
            -jpeg)
                COMPREPLY=($( compgen -W 'noprogressive progressive \
    					nobaseline baseline optimize= \
    					smooth= quality= outdir=' -- $cur ));
                return 0
            ;;
            -xvidopts)
                COMPREPLY=($( compgen -W 'dr2 nodr2' -- $cur ));
                return 0
            ;;
            -xvidencopts)
                COMPREPLY=($( compgen -W 'pass= bitrate= \
    					fixed_quant= me_quality= 4mv \
    					rc_reaction_delay_factor= \
    					rc_averaging_period= rc_buffer= \
    					quant_range= min_key_interval= \
    					max_key_interval= mpeg_quant \
    					mod_quant lumi_mask hintedme \
    					hintfile debug keyframe_boost= \
    					kfthreshold= kfreduction=' -- $cur ));
                return 0
            ;;
            -divx4opts)
                COMPREPLY=($( compgen -W 'br= key= deinterlace q= \
    					min_quant= max_quant= rc_period= \
    					rc_reaction_period= crispness= \
    					rc_reaction_ratio= pass= vbrpass= \
    					help' -- $cur ));
                return 0
            ;;
            -info)
                COMPREPLY=($( compgen -W 'name= artist= genre= \
    					subject= copyright= srcform= \
    					comment= help' -- $cur ));
                return 0
            ;;
            -lameopts)
                COMPREPLY=($( compgen -W 'vbr= abr cbr br= q= aq= \
    					ratio= vol= mode= padding= fast \
    					preset= help' -- $cur ));
                return 0
            ;;
            -rawaudio)
                COMPREPLY=($( compgen -W 'on channels= rate= \
    					samplesize= format=' -- $cur ));
                return 0
            ;;
            -rawvideo)
                COMPREPLY=($( compgen -W 'on fps= sqcif qcif cif \
    					4cif pal ntsc w= h= y420 yv12 yuy2 \
    					y8 format= size=' -- $cur ));
                return 0
            ;;
            -aop)
                COMPREPLY=($( compgen -W 'list= delay= format= fout= \
    					volume= mul= softclip' -- $cur ));
                return 0
            ;;
            -dxr2)
                COMPREPLY=($( compgen -W 'ar-mode= iec958-encoded \
    					iec958-decoded mute ucode= 75ire bw \
    					color interlaced macrovision= norm= \
    					square-pixel ccir601-pixel cr-left= \
    					cr-right= cr-top= cr-bot= ck-rmin= \
    					ck-gmin= ck-bmin= ck-rmax= ck-gmax= \
    					ck-bmax= ck-r= ck-g= ck-b= \
    					ignore-cache= ol-osd= olh-cor= \
    					olw-cor= olx-cor= oly-cor= overlay \
    					overlay-ratio= update-cache' -- $cur ));
                return 0
            ;;
            -tv)
                COMPREPLY=($( compgen -W 'on noaudio driver= device= \
    					input= freq= outfmt= width= height= \
    					buffersize= norm= channel= chanlist= \
    					audiorate= forceaudio alsa amode= \
    					forcechan= adevice= audioid= volume= \
    					bass= treble= balance= fps= \
    					channels= immediatemode=' -- $cur ));
                return 0
            ;;
            -mf)
                COMPREPLY=($( compgen -W 'on w= h= fps= type=' 					-- $cur ));
                return 0
            ;;
            -cdda)
                COMPREPLY=($( compgen -W 'speed= paranoia= \
    					generic-dev= sector-size= overlap= \
    					toc-bias toc-offset= skip noskip' 					-- $cur ));
                return 0
            ;;
            -input)
                COMPREPLY=($( compgen -W 'conf= ar-delay ar-rate \
    					keylist cmdlist js-dev file' -- $cur ));
                return 0
            ;;
            -af)
                COMPREPLY=($( compgen -W 'resample resample= \
    					channels channels= format format= \
    					volume volume= delay delay= pan \
    					pan= sub sub= surround surround=' 					-- $cur ));
                return 0
            ;;
            -af-adv)
                COMPREPLY=($( compgen -W 'force= list=' -- $cur ));
                return 0
            ;;
        esac;
        case "$cur" in 
            -*)
                COMPREPLY=($( compgen -W '-aid -alang -audio-demuxer \
    					-audiofile -cdrom-device -cache -cdda \
    					-channels -chapter -csslib -demuxer \
    					-dvd -dvd-device -dvdangle -dvdauth \
    					-dvdkey -dvdnav -forceidx -fps -frames \
    					-hr-mp3-seek -idx -mc -mf -ni -nobps \
    					-passwd -rawaudio -rtsp-stream-over-tcp\
    					-skipopening -sb -srate -ss -tv -user \
    					-vcd -vid -vivo -ifo -ffactor -font \
    					-noautosub -nooverlapsub -sid -slang \
    					-sub -subcc -subcp -sub-demuxer \
    					-subdelay -subfont-autoscale \
    					-subfont-blur -subfont-encoding \
    					-subfont-osd-scale -subfont-outline \
    					-subfont-text-scale -subfps -subfile \
    					-subpos -unicode -utf8 -vobsub \
    					-vobsubid -ac -afm -aspect -flip \
    					-lavdopts -noaspect -nosound -pp -ssf \
    					-stereo -sws -vc -vfm -vop -xvidopts\
    					-xy -zoom -bandwidth -cuefile \
    					-noextbased -rawvideo -overlapsub \
    					-sub-bg-alpha -sub-bg-color -subalign \
    					-subwidth -sub-no-text-pp -spualign \
    					-spuaa -spugauss -pphelp -verbose -v \
    					-noni -noidx -nohr-mp3-seek -extbased \
    					-bps -oldpp -nozoom -noflip -nounicode \
    					-noutf8' -- $cur ));
                [[ "$cmd" == @(?(g)mplayer) ]] && COMPREPLY=("${COMPREPLY[@]}" $(compgen -W '-autoq -autosync -benchmark \
    					-framedrop -h -help -hardframedrop \
    					-identify -input -lircconf -loop \
    					-nojoystick -nolirc -nortc -playlist \
    					-quiet -really-quiet -rnd -sdp -skin \
    					-slave -softsleep -speed -sstep \
    					-use-stdin -dumpaudio -dumpfile \
    					-dumpstream -dumpvideo -dumpmicrodvdsub\
    					-dumpmpsub -dumpsrtsub -dumpjacosub \
    					-dumpsami -dumpsub -osdlevel -af \
    					-af-adv -ao -aofile -aop -delay -mixer \
    					-nowaveheader -bpp -brightness \
    					-contrast -display -double -dr -dxr2 \
    					-fb -fbmode -fbmodeconfig -forcexv -fs \
    					-geometry -hue -icelayer -jpeg \
    					-monitor-dotclock -monitor-hfreq \
    					-monitor-vfreq -monitoraspect \
    					-nograbpointer -noslices -panscan \
    					-rootwin -saturation -screenw -screenh \
    					-stop-xscreensaver -vm -vo -vsync -wid \
    					-xineramascreen -z -zrbw -zrcrop \
    					-zrdev -zrfd -zrhelp -zrnorm -zrquality \
    					-zrvdec -zrhdec -zrxdoff -zrydoff -y \
    					-edl -edlout -enqueue -fixed-vo \
    					-menu -menu-root -menu-cfg -shuffle \
    					-format -aahelp -dfbopts -fstype \
    					-guiwid -nokeepaspect -x --help \
    					-aaosdcolor -aasubcolor -aadriver \
    					-aaextended -aaeight' -- $cur));
                [[ "$cmd" = mencoder ]] && COMPREPLY=("${COMPREPLY[@]}" $(compgen -W '-audio-density -audio-delay \
    					-audio-preload -divx4opts -endpos \
    					-ffourcc -include -info -lameopts \
    					-lavcopts -noskip -o -oac -ofps -ovc \
    					-passlogfile -skiplimit -vobsubout \
    					-vobsuboutindex -vobsuboutid \
    					-xvidencopts -of --verbose' -- $cur))
            ;;
            *)
                _filedir '@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|ASF|vob|VOB|bin|BIN|dat|DAT|vcd|VCD|ps|PS|pes|PES|fli|FLI|flv|FLV|viv|VIV|rm?(j)|RM?(J)|ra?(m)|RA?(M)|yuv|YUV|mov|MOV|qt|QT|mp[34]|MP[34]|m4v|M4V|og[gm]|OG[GM]|wav|WAV|dump|DUMP|mk[av]|MK[AV]|m4a|M4A|aac|AAC|m2v|M2V|dv|DV|rmvb|RMVB|mid|MID|ts|TS|3gp|mpc|MPC|flac|FLAC|flv|FLV|divx|DIVX)'
            ;;
        esac;
        return 0
    }
    _mplayer_options_list () 
    { 
        cur=${cur%\\};
        COMPREPLY=($( $1 $2 help 2> /dev/null | 		sed -e '1,/^Available/d' | awk '{print $1}' | 		sed -e 's/:$//' -e 's/^'${2#-}'$//' -e 's/<.*//' | 		grep "^$cur" ))
    }
    _nslookup () 
    { 
        local cur;
        COMPREPLY=();
        cur=${COMP_WORDS[COMP_CWORD]#-};
        COMPREPLY=($( compgen -P '-' -W 'all class= debug d2 domain= \
    			       srchlist= defname search port= querytype= \
    			       type= recurse retry root timeout vc \
    			       ignoretc' -- $cur ))
    }
    _ntpdate () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case $prev in 
            -k)
                _filedir;
                return 0
            ;;
            -U)
                COMPREPLY=($( compgen -u $cur  ));
                return 0
            ;;
        esac;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-4 -6 -b -B -d -Q -q -s -u -v -a\
    			-e -k -p -o -r -t' -- $cur ));
        else
            _known_hosts;
        fi
    }
    _ooexp_ () 
    { 
        local c=${COMP_WORDS[COMP_CWORD]};
        local a="${COMP_LINE}";
        local e s g=0 cd dc t="";
        local IFS;
        shopt -q extglob && g=1;
        test $g -eq 0 && shopt -s extglob;
        cd='*-?(c)d*';
        dc='*-d?(c)*';
        case "${1##*/}" in 
            oobase)
                e='!*.+(odb|ODB)'
            ;;
            oofromtemplate)
                e='!*.+(stw|STW|dot|DOT|vor|VOR|stc|STC|xlt|XLT|sti|STI|pot|POT|std|STD|stw|STW|dotm|DOTM|dotx|DOTX|potm|POTM|potx|POTX|xltm|XLTM|xltx|XLTX)'
            ;;
            oodraw)
                e='!*.+(sxd|SXD|std|STD|dxf|DXF|emf|EMF|eps|EPS|met|MET|pct|PCT|sgf|SGF|sgv|SGV|sda|SDA|sdd|SDD|vor|VOR|svm|SVM|wmf|WMF|bmp|BMP|gif|GIF|jpg|JPG|jpeg|JPEG|jfif|JFIF|fif|FIF|jpe|JPE|pcd|PCD|pcx|PCX|pgm|PGM|png|PNG|ppm|PPM|psd|PSD|ras|RAS|tga|TGA|tif|TIF|tiff|TIFF|xbm|XBM|xpm|XPM|odg|ODG|otg|OTG|fodg|FODG|odc|ODC|odi|ODI|sds|SDS|wpg|WPG)'
            ;;
            oocalc)
                e='!*.+(sxc|SXC|stc|STC|dif|DIF|dbf|DBF|xls|XLS|xlw|XLW|xlt|XLT|rtf|RTF|sdc|SDC|vor|VOR|slk|SLK|txt|TXT|htm|HTM|html|HTML|wk1|WK1|wks|WKS|123|123|xml|XML|ods|ODS|ots|OTS|fods|FODS|csv|CSV|xlsb|XLSB|xlsm|XLSM|xlsx|XLSX|xltm|XLTM|xltx|XLTX)'
            ;;
            oomath)
                e='!*.+(sxm|SXM|smf|SMF|mml|MML|odf|ODF)'
            ;;
            ooweb)
                e='!*.+(htm|HTM|html|HTML|stw|STW|txt|TXT|vor|VOR|oth|OTH)'
            ;;
            ooffice)
                e='!*.+(sxd|SXD|std|STD|dxf|DXF|emf|EMF|eps|EPS|met|MET|pct|PCT|sgf|SGF|sgv|SGV|sda|SDA|sdd|SDD|vor|VOR|svm|SVM|wmf|WMF|bmp|BMP|gif|GIF|jpg|JPG|jpeg|JPEG|jfif|JFIF|fif|FIF|jpe|JPE|pcd|PCD|pcx|PCX|pgm|PGM|png|PNG|ppm|PPM|psd|PSD|ras|RAS|tga|TGA|tif|TIF|tiff|TIFF|xbm|XBM|xpm|XPM|odg|ODG|otg|OTG|fodg|FODG|odc|ODC|odi|ODI|sds|SDS|wpg|WPG|doc|DOC|dot|DOT|rtf|RTF|sxw|SXW|stw|STW|sdw|SDW|vor|VOR|txt|TXT|htm?|HTM?|xml|XML|wp|WP|wpd|WPD|wps|WPS|odt|ODT|ott|OTT|fodt|FODT|docm|DOCM|docx|DOCX|dotm|DOTM|dotx|DOTX|sxm|SXM|smf|SMF|mml|MML|odf|ODF|sxi|SXI|sti|STI|ppt|PPT|pps|PPS|pot|POT|sxd|SXD|sda|SDA|sdd|SDD|sdp|SDP|vor|VOR|cgm|CGM|odp|ODP|otp|OTP|fodp|FODP|ppsm|PPSM|ppsx|PPSX|pptm|PPTM|pptx|PPTX|potm|POTM|potx|POTX|odb|ODB|sxc|SXC|stc|STC|dif|DIF|dbf|DBF|xls|XLS|xlw|XLW|xlt|XLT|rtf|RTF|sdc|SDC|vor|VOR|slk|SLK|txt|TXT|htm|HTM|html|HTML|wk1|WK1|wks|WKS|123|123|xml|XML|ods|ODS|ots|OTS|fods|FODS|csv|CSV|xlsb|XLSB|xlsm|XLSM|xlsx|XLSX|xltm|XLTM|xltx|XLTX|sxg|SXG|odm|ODM|sgl|SGL|stw|STW|dot|DOT|vor|VOR|stc|STC|xlt|XLT|sti|STI|pot|POT|std|STD|stw|STW|dotm|DOTM|dotx|DOTX|potm|POTM|potx|POTX|xltm|XLTM|xltx|XLTX|htm|HTM|html|HTML|stw|STW|txt|TXT|vor|VOR|oth|OTH)'
            ;;
            oowriter)
                e='!*.+(doc|DOC|dot|DOT|rtf|RTF|sxw|SXW|stw|STW|sdw|SDW|vor|VOR|txt|TXT|htm?|HTM?|xml|XML|wp|WP|wpd|WPD|wps|WPS|odt|ODT|ott|OTT|fodt|FODT|docm|DOCM|docx|DOCX|dotm|DOTM|dotx|DOTX|sxg|SXG|odm|ODM|sgl|SGL)'
            ;;
            ooimpress)
                e='!*.+(sxi|SXI|sti|STI|ppt|PPT|pps|PPS|pot|POT|sxd|SXD|sda|SDA|sdd|SDD|sdp|SDP|vor|VOR|cgm|CGM|odp|ODP|otp|OTP|fodp|FODP|ppsm|PPSM|ppsx|PPSX|pptm|PPTM|pptx|PPTX|potm|POTM|potx|POTX)'
            ;;
            unopkg)
                e='!*.+(oxt|OXT)'
            ;;
            *)
                e='!*'
            ;;
        esac;
        case "$(complete -p ${1##*/} 2> /dev/null)" in 
            *-d*)
    
            ;;
            *)
                s="-S/"
            ;;
        esac;
        IFS='
    ';
        case "$c" in 
            \$\(*\))
                eval COMPREPLY=\(${c}\)
            ;;
            \$\(*)
                COMPREPLY=($(compgen -c -P '$(' -S ')'  -- ${c#??}))
            ;;
            \`*\`)
                eval COMPREPLY=\(${c}\)
            ;;
            \`*)
                COMPREPLY=($(compgen -c -P '\`' -S '\`' -- ${c#?}))
            ;;
            \$\{*\})
                eval COMPREPLY=\(${c}\)
            ;;
            \$\{*)
                COMPREPLY=($(compgen -v -P '${' -S '}'  -- ${c#??}))
            ;;
            \$*)
                COMPREPLY=($(compgen -v -P '$'          -- ${c#?}))
            ;;
            \~*/*)
                COMPREPLY=($(compgen -f -X "$e"         -- ${c}))
            ;;
            \~*)
                COMPREPLY=($(compgen -u ${s}	 	-- ${c}))
            ;;
            *@*)
                COMPREPLY=($(compgen -A hostname -P '@' -S ':' -- ${c#*@}))
            ;;
            *[*?[]*)
                COMPREPLY=($(compgen -G "${c}"))
            ;;
            *[?*+\!@]\(*\)*)
                if test $g -eq 0; then
                    COMPREPLY=($(compgen -f -X "$e" -- $c));
                    test $g -eq 0 && shopt -u extglob;
                    return;
                fi;
                COMPREPLY=($(compgen -G "${c}"))
            ;;
            *)
                if test "$c" = ".."; then
                    COMPREPLY=($(compgen -d -X "$e" -S / ${_nosp} -- $c));
                else
                    for s in $(compgen -f -X "$e" -- $c);
                    do
                        if test -d $s; then
                            COMPREPLY=(${COMPREPLY[@]} $(compgen -f -X "$e" -S / -- $s));
                        else
                            if test -z "$t"; then
                                COMPREPLY=(${COMPREPLY[@]} $s);
                            else
                                case "$(file -b $s 2> /dev/null)" in 
                                    $t)
                                        COMPREPLY=(${COMPREPLY[@]} $s)
                                    ;;
                                esac;
                            fi;
                        fi;
                    done;
                fi
            ;;
        esac;
        test $g -eq 0 && shopt -u extglob
    }
    _openssl () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        if [ $COMP_CWORD -eq 1 ]; then
            COMPREPLY=($( compgen -W 'asn1parse ca ciphers crl crl2pkcs7 \
    			dgst dh dhparam dsa dsaparam enc errstr gendh gendsa \
    			genrsa nseq passwd pkcs12 pkcs7 pkcs8 rand req rsa \
    			rsautl s_client s_server s_time sess_id smime speed \
    			spkac verify version x509 md2 md4 md5 mdc2 rmd160 sha \
    			sha1 base64 bf bf-cbc bf-cfb bf-ecb bf-ofb cast \
    			cast-cbc cast5-cbc cast5-cfb cast5-ecb cast5-ofb des \
    			des-cbc des-cfb des-ecb des-ede des-ede-cbc \
    			des-ede-cfb des-ede-ofb des-ede3 des-ede3-cbc \
    			des-ede3-cfb des-ede3-ofb des-ofb des3 desx rc2 \
    			rc2-40-cbc rc2-64-cbc rc2-cbc rc2-cfb rc2-ecb rc2-ofb \
    			rc4 rc4-40' -- $cur ));
        else
            prev=${COMP_WORDS[COMP_CWORD-1]};
            case ${COMP_WORDS[1]} in 
                asn1parse)
                    case $prev in 
                        -inform)
                            COMPREPLY=($( compgen -W 'DER PEM' -- $cur ));
                            return 0
                        ;;
                        -@(in|out|oid))
                            _filedir;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-inform -in -out -noout -offset \
    						-length -i -oid -strparse' -- $cur ));
                    fi
                ;;
                ca)
                    case $prev in 
                        -@(config|revoke|cert|in|out|spkac|ss_cert))
                            _filedir;
                            return 0
                        ;;
                        -outdir)
                            _filedir -d;
                            return 0
                        ;;
                        -@(name|crlexts|extensions))
                            _openssl_sections;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-verbose -config -name \
    						-gencrl -revoke -crldays -crlhours -crlexts \
    						-startdate -enddate -days -md -policy -keyfile \
    						-key -passin -cert -in -out -notext -outdir \
    						-infiles -spkac -ss_cert -preserveDN -batch \
    						-msie_hack -extensions' -- $cur ));
                    fi
                ;;
                ciphers)
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-v -ssl2 -ssl3 -tls1' -- $cur ));
                    fi
                ;;
                crl)
                    case $prev in 
                        -@(in|out)form)
                            COMPREPLY=($( compgen -W 'DER PEM' -- $cur ));
                            return 0
                        ;;
                        -@(in|out|CAfile))
                            _filedir;
                            return 0
                        ;;
                        -CAPath)
                            _filedir -d;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-inform -outform -text -in -out -noout \
    						-hash -issuer -lastupdate -nextupdate -CAfile -CApath' -- $cur ));
                    fi
                ;;
                crl2pkcs7)
                    case $prev in 
                        -@(in|out)form)
                            COMPREPLY=($( compgen -W 'DER PEM' -- $cur ));
                            return 0
                        ;;
                        -@(in|out))
                            _filedir;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-inform -outform -in -out -print_certs' -- $cur ));
                    fi
                ;;
                dgst)
                    case $prev in 
                        -@(out|sign|verify|prvrify|signature))
                            _filedir;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-md5 -md4 -md2 -sha1 -sha -mdc2 -ripemd160 -dss1 \
    						-c -d -hex -binary -out -sign -verify -prverify -signature' -- $cur ));
                    else
                        _filedir;
                    fi
                ;;
                dsa)
                    case $prev in 
                        -@(in|out)form)
                            COMPREPLY=($( compgen -W 'DER PEM' -- $cur ));
                            return 0
                        ;;
                        -@(in|out))
                            _filedir;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-inform -outform -in -passin -out -passout -des -des3 -idea -text -noout \
    						-modulus -pubin -pubout' -- $cur ));
                    fi
                ;;
                dsaparam)
                    case $prev in 
                        -@(in|out)form)
                            COMPREPLY=($( compgen -W 'DER PEM' -- $cur ));
                            return 0
                        ;;
                        -@(in|out|rand))
                            _filedir;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-inform -outform -in -out -noout \
    						-text -C -rand -genkey' -- $cur ));
                    fi
                ;;
                enc)
                    case $prev in 
                        -@(in|out|kfile))
                            _filedir;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-ciphername -in -out -pass \
    						-e -d -a -A -k -kfile -S -K -iv -p -P -bufsize -debug' -- $cur ));
                    fi
                ;;
                dhparam)
                    case $prev in 
                        -@(in|out)form)
                            COMPREPLY=($( compgen -W 'DER PEM' -- $cur ));
                            return 0
                        ;;
                        -@(in|out|rand))
                            _filedir;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-inform -outform -in -out -dsaparam -noout \
    						-text -C -2 -5 -rand' -- $cur ));
                    fi
                ;;
                gendsa)
                    case $prev in 
                        -@(out|rand))
                            _filedir;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-out -des -des3 -idea -rand' -- $cur ));
                    else
                        _filedir;
                    fi
                ;;
                genrsa)
                    case $prev in 
                        -@(out|rand))
                            _filedir;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-out -passout -des -des3 -idea -f4 -3 -rand' -- $cur ));
                    fi
                ;;
                pkcs7)
                    case $prev in 
                        -@(in|out)form)
                            COMPREPLY=($( compgen -W 'DER PEM' -- $cur ));
                            return 0
                        ;;
                        -@(in|out))
                            _filedir;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-inform -outform -in -out -print_certs -text -noout' -- $cur ));
                    fi
                ;;
                rand)
                    case $prev in 
                        -@(out|rand))
                            _filedir;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-out -rand -base64' -- $cur ));
                    fi
                ;;
                req)
                    case "$prev" in 
                        -@(in|out|key)form)
                            COMPREPLY=($( compgen -W 'DER PEM' -- $cur ));
                            return 0
                        ;;
                        -@(in|out|rand|key|keyout|config))
                            _filedir;
                            return 0
                        ;;
                        -extensions)
                            _openssl_sections;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-inform -outform -in \
    						-passin -out -passout -text -noout -verify \
    						-modulus -new -rand -newkey -newkey -nodes \
    						-key -keyform -keyout -md5 -sha1 -md2 -mdc2 \
    						-config -x509 -days -asn1-kludge -newhdr \
    						-extensions -reqexts section' -- $cur ));
                    fi
                ;;
                rsa)
                    case $prev in 
                        -@(in|out)form)
                            COMPREPLY=($( compgen -W 'DER NET PEM' -- $cur ));
                            return 0
                        ;;
                        -@(in|out))
                            _filedir;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-inform -outform -in -passin -out -passout \
    						-sgckey -des -des3 -idea -text -noout -modulus -check -pubin \
    						-pubout -engine' -- $cur ));
                    fi
                ;;
                rsautl)
                    case $prev in 
                        -@(in|out|inkey))
                            _filedir;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-in -out -inkey -pubin -certin -sign -verify \
    						-encrypt -decrypt -pkcs -ssl -raw -hexdump -asn1parse' -- $cur ));
                    fi
                ;;
                s_client)
                    case $prev in 
                        -connect)
                            _known_hosts;
                            return 0
                        ;;
                        -@(cert|key|CAfile|rand))
                            _filedir;
                            return 0
                        ;;
                        -CApath)
                            _filedir -d;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-connect -verify -cert -key -CApath -CAfile \
    						-reconnect -pause -showcerts -debug -msg -nbio_test -state -nbio \
    						-crlf -ign_eof -quiet -ssl2 -ssl3 -tls1 -no_ssl2 -no_ssl3 -no_tls1 \
    						-bugs -cipher -starttls -engine -rand' -- $cur ));
                    fi
                ;;
                s_server)
                    case $prev in 
                        -@(cert|key|dcert|dkey|dhparam|CAfile|rand))
                            _filedir;
                            return 0
                        ;;
                        -CApath)
                            _filedir -d;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-accept -context -verify -Verify -cert -key \
    						 -dcert -dkey -dhparam -nbio -nbio_test -crlf -debug -msg -state -CApath \
    						 -CAfile -nocert -cipher -quiet -no_tmp_rsa -ssl2 -ssl3 -tls1 -no_ssl2 \
    						 -no_ssl3 -no_tls1 -no_dhe -bugs -hack -www -WWW -HTTP -engine -id_prefix \
    						 -rand' -- $cur ));
                    fi
                ;;
                s_time)
                    case $prev in 
                        -connect)
                            _known_hosts;
                            return 0
                        ;;
                        -@(cert|key|CAfile))
                            _filedir;
                            return 0
                        ;;
                        -CApath)
                            _filedir -d;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-connect -www -cert -key -CApath -CAfile -reuse \
    						-new -verify -nbio -time -ssl2 -ssl3 -bugs -cipher' -- $cur ));
                    fi
                ;;
                sess_id)
                    case $prev in 
                        -@(in|out)form)
                            COMPREPLY=($( compgen -W 'DER PEM' -- $cur ));
                            return 0
                        ;;
                        -@(in|out))
                            _filedir;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-inform -outform -in -out -text -noout \
    						-context ID' -- $cur ));
                    fi
                ;;
                smime)
                    case $prev in 
                        -@(in|out)form)
                            COMPREPLY=($( compgen -W 'SMIME DER PEM' -- $cur ));
                            return 0
                        ;;
                        -@(in|out|certfile|signer|recip|inkey|content|rand))
                            _filedir;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-encrypt -decrypt -sign -verify -pk7out -des -des3 \
    						-rc2-40 -rc2-64 -rc2-128 -aes128 -aes192 -aes256 -in -certfile -signer \
    						-recip -inform -passin -inkey -out -outform -content -to -from -subject \
    						-text -rand' -- $cur ));
                    else
                        _filedir;
                    fi
                ;;
                speed)
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-engine' -- $cur ));
                    else
                        COMPREPLY=($( compgen -W 'md2 mdc2 md5 hmac sha1 rmd160 idea-cbc \
    						rc2-cbc rc5-cbc bf-cbc des-cbc des-ede3 rc4 rsa512 rsa1024 rsa2048 \
    						rsa4096 dsa512 dsa1024 dsa2048 idea rc2 des rsa blowfish' -- $cur ));
                    fi
                ;;
                verify)
                    case $prev in 
                        -@(CAfile|untrusted))
                            _filedir;
                            return 0
                        ;;
                        -CApath)
                            _filedir -d;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-CApath -CAfile -purpose -untrusted -help -issuer_checks \
    						-verbose -certificates' -- $cur ));
                    else
                        _filedir;
                    fi
                ;;
                x509)
                    case "$prev" in 
                        -@(in|out|CA|CAkey|CAserial|extfile))
                            _filedir;
                            return 0
                        ;;
                        -@(in|out)form)
                            COMPREPLY=($( compgen -W 'DER PEM NET' -- $cur ));
                            return 0
                        ;;
                        -@(key|CA|CAkey)form)
                            COMPREPLY=($( compgen -W 'DER PEM' -- $cur ));
                            return 0
                        ;;
                        -extensions)
                            _openssl_sections;
                            return 0
                        ;;
                    esac;
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-inform -outform \
    						-keyform -CAform -CAkeyform -in -out \
    						-serial -hash -subject -issuer -nameopt \
    						-email -startdate -enddate -purpose \
    						-dates -modulus -fingerprint -alias \
    						-noout -trustout -clrtrust -clrreject \
    						-addtrust -addreject -setalias -days \
    						-set_serial -signkey -x509toreq -req \
    						-CA -CAkey -CAcreateserial -CAserial \
    						-text -C -md2 -md5 -sha1 -mdc2 -clrext \
    						-extfile -extensions -engine' -- $cur ));
                    fi
                ;;
                @(md5|md4|md2|sha1|sha|mdc2|ripemd160))
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '-c -d' -- $cur ));
                    else
                        _filedir;
                    fi
                ;;
            esac;
        fi;
        return 0
    }
    _openssl_sections () 
    { 
        local config;
        config=/etc/ssl/openssl.cnf;
        [ ! -f $config ] && config=/usr/share/ssl/openssl.cnf;
        for ((i=2; i < COMP_CWORD; i++ ))
        do
            if [[ "${COMP_WORDS[i]}" == -config ]]; then
                config=${COMP_WORDS[i+1]};
                break;
            fi;
        done;
        [ ! -f $config ] && return 0;
        COMPREPLY=($( awk '/\[.*\]/ {print $2} ' $config | grep "^$cur" ))
    }
    _perl () 
    { 
        local cur prev prefix temp;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        prefix="";
        if [[ "$cur" == -?* ]]; then
            temp=$cur;
            prev=${temp:0:2};
            cur=${temp:2};
            prefix=$prev;
        fi;
        case "$prev" in 
            -I | -x)
                COMPREPLY=($( compgen -d -P "$prev" -- "$cur" ));
                return 0
            ;;
            -m | -M)
                _perlmodules;
                return 0
            ;;
        esac;
        if [[ "${COMP_WORDS[COMP_CWORD]}" != -* ]]; then
            _filedir;
            return 0;
        fi;
        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 ));
        return 0
    }
    _perldoc () 
    { 
        local cur prev prefix temp;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        prefix="";
        if [[ "$cur" == -?* ]]; then
            temp=$cur;
            prev=${temp:0:2};
            cur=${temp:2};
            prefix=$prev;
        fi;
        case $prev in 
            -f)
                COMPREPLY=($( compgen -W 'chomp chop chr crypt hex index lc \
    	    lcfirst length oct ord pack q qq reverse rindex sprintf \
    	    substr tr uc ucfirst y m pos quotemeta s split study qr abs \
    	    atan2 cos exp hex int log oct rand sin sqrt srand pop push \
    	    shift splice unshift grep join map qw reverse sort unpack \
    	    delete each exists keys values binmode close closedir \
    	    dbmclose dbmopen die eof fileno flock format getc print \
    	    printf read readdir rewinddir seek seekdir select syscall \
    	    sysread sysseek syswrite tell telldir truncate warn write \
    	    pack read syscall sysread syswrite unpack vec -X chdir chmod \
    	    chown chroot fcntl glob ioctl link lstat mkdir open opendir \
    	    readlink rename rmdir stat symlink umask unlink utime caller \
    	    continue do dump eval exit goto last next redo return \
    	    sub wantarray caller import local my our package use defined \
    	    formline reset scalar undef \
    	    alarm exec fork getpgrp getppid getpriority kill pipe qx \
    	    setpgrp setpriority sleep system times wait waitpid \
    	    import no package require use bless dbmclose dbmopen package \
    	    ref tie tied untie use accept bind connect getpeername \
    	    getsockname getsockopt listen recv send setsockopt shutdown \
    	    socket socketpair msgctl msgget msgrcv msgsnd semctl semget \
    	    semop shmctl shmget shmread shmwrite endgrent endhostent \
    	    endnetent endpwent getgrent getgrgid getgrnam getlogin \
    	    getpwent getpwnam getpwuid setgrent setpwent endprotoent \
    	    endservent gethostbyaddr gethostbyname gethostent \
    	    getnetbyaddr getnetbyname getnetent getprotobyname \
    	    getprotobynumber getprotoent getservbyname getservbyport \
    	    getservent sethostent setnetent setprotoent setservent \
    	    gmtime localtime time times' -- $cur ));
                return 0
            ;;
        esac;
        case $cur in 
            -*)
                COMPREPLY=($( compgen -W '-h -v -t -u -m -l -F -X -f -q' -- $cur ));
                return 0
            ;;
            */*)
                return 0
            ;;
            *)
                _perlmodules;
                COMPREPLY=("${COMPREPLY[@]}" $( compgen -W '$( PAGER=cat man perl 2>/dev/null | sed -ne "/perl.*Perl overview/,/perlwin32/s/^[^a-z0-9]*\([a-z0-9]*\).*$/\1/p")' -- $cur ));
                return 0
            ;;
        esac
    }
    _perlmodules () 
    { 
        COMPREPLY=($( compgen -P "$prefix" -W "$( perl -e 'sub mods { my ($base,$dir)=@_; return if  $base !~ /^\Q$ENV{cur}/; chdir($dir) or return; for (glob(q[*.pm])) {s/\.pm$//; print qq[$base$_\n]}; mods(/^(?:[.\d]+|$Config{archname}-$Config{osname}|auto)$/ ? undef : qq[${base}${_}\\\\:\\\\:],qq[$dir/$_]) for grep {-d} glob(q[*]); } mods(undef,$_) for @INC;' )" -- $cur ))
    }
    _pgids () 
    { 
        COMPREPLY=($( compgen -W '$( command ps axo pgid | sed 1d )' -- $cur ))
    }
    _pgrep () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        COMPREPLY=($( compgen -W '$( command ps axo command | \
    		      sed -ne "1d; s/^\[\?\([^-][^] ]*\).*$/\1/p" | \
    		      sed -e "s/.*\///" )' -- $cur ));
        return 0
    }
    _pids () 
    { 
        COMPREPLY=($( compgen -W '$( command ps axo pid | sed 1d )' -- $cur ))
    }
    _pkcon () 
    { 
        local i c=1 command;
        while [ $c -lt $COMP_CWORD ]; do
            i="${COMP_WORDS[c]}";
            case "$i" in 
                --version | --help | --verbose | --nowait | -v | -n | -h | -?)
    
                ;;
                *)
                    command="$i";
                    break
                ;;
            esac;
            c=$((++c));
        done;
        if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
            case "${COMP_WORDS[COMP_CWORD]}" in 
                --*=*)
                    COMPREPLY=()
                ;;
                --*)
                    __pkconcomp "
    			--version
    			--filter
    			--verbose
                --help
                --nowait
    			"
                ;;
                -*)
                    __pkconcomp "
                -v
                -n
                -h
                -?
    			--version
    			--verbose
                --help
                --filter
                --nowait
                "
                ;;
                *)
                    __pkconcomp "$__pkcon_commandlist"
                ;;
            esac;
            return;
        fi;
        case "$command" in 
            search)
                _pkcon_search
            ;;
            *)
                COMPREPLY=()
            ;;
        esac
    }
    _pkcon_search () 
    { 
        local i c=1 command;
        while [ $c -lt $COMP_CWORD ]; do
            i="${COMP_WORDS[c]}";
            case "$i" in 
                name | details | group | file)
                    command="$i";
                    break
                ;;
            esac;
            c=$((++c));
        done;
        if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
            __pkconcomp "name details group file";
        fi;
        return
    }
    _pkg_config () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-version --modversion \
    		      --atleast-pkgconfig-version= --libs --libs-only-l \
    		      --libs-only-other --libs-only-L --cflags \
    		      --cflags-only-I --cflags-only-other --variable= \
    		      --define-variable= --exists --uninstalled \
    		      --atleast-version= --exact-version= --max-version= \
    		      --list-all --debug --print-errors --silence-errors \
    		      --errors-to-stdout -? --help --usage' -- $cur));
        else
            COMPREPLY=($( pkg-config --list-all 2>/dev/null | 				    awk '{print $1}' | grep "^$cur" ));
        fi
    }
    _poff () 
    { 
        local prev cur conns;
        [ -r /etc/ppp/peers/ ] || return 0;
        COMPREPLY=();
        prev=${COMP_WORDS[COMP_CWORD-1]};
        cur=${COMP_WORDS[COMP_CWORD]};
        conns=$(\ls --color=none /etc/ppp/peers | egrep -v '(\.bak|~)$');
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($(compgen -W '-r -d -c -a -h -v' -- $cur));
            return 0;
        fi;
        if [ $COMP_CWORD -eq 1 ] && [[ "$cur" != -* ]] || [[ "$prev" == -* ]]; then
            COMPREPLY=($(compgen -o filenames -W "$conns" $cur));
        fi;
        return 0
    }
    _pon () 
    { 
        local cur conns;
        [ -r /etc/ppp/peers/ ] || return 0;
        COMPREPLY=();
        cur=${COMP_WORDS[COMP_CWORD]};
        conns=$(\ls --color=none /etc/ppp/peers | egrep -v '(\.bak|~)$');
        if [ $COMP_CWORD -eq 1 ]; then
            COMPREPLY=($(compgen -o filenames -W "$conns" $cur));
        fi;
        return 0
    }
    _python () 
    { 
        local prev cur;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]##*/};
        case "$prev" in 
            -Q)
                COMPREPLY=($( compgen -W "old new warn warnall" -- $cur ));
                return 0
            ;;
            -W)
                COMPREPLY=($( compgen -W "ignore default all module once error" -- $cur ));
                return 0
            ;;
            -c)
                _filedir '@(py|pyc|pyo)';
                return 0
            ;;
            !(python|-?))
                [[ ${COMP_WORDS[COMP_CWORD-2]} != -@(Q|W) ]] && _filedir
            ;;
        esac;
        for ((i=0; i < ${#COMP_WORDS[@]}-1; i++ ))
        do
            if [[ ${COMP_WORDS[i]} == -c ]]; then
                _filedir;
            fi;
        done;
        if [[ "$cur" != -* ]]; then
            _filedir '@(py|pyc|pyo)';
        else
            COMPREPLY=($( compgen -W "- -d -E -h -i -O -Q -S -t -u 					   -U -v -V -W -x -c" -- $cur ));
        fi;
        return 0
    }
    _remove_comp_word () 
    { 
        if [[ COMP_CWORD -eq 0 ]]; then
            return;
        else
            if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
                local old_cw0="${COMP_WORDS[0]}";
                local new_cw0="${COMP_WORDS[1]}";
                local old_length="${#COMP_LINE}";
                COMP_LINE=${COMP_LINE#${old_cw0}};
                local head=${COMP_LINE:0:${#new_cw0}};
                local i=1;
                while [[ $head != $new_cw0 ]]; do
                    COMP_LINE=${COMP_LINE:1};
                    head=${COMP_LINE:0:${#new_cw0}};
                    if (( ++i > 10 )); then
                        break;
                    fi;
                done;
                local new_length="${#COMP_LINE}";
                COMP_POINT=$(( COMP_POINT + new_length - old_length));
                COMP_CWORD=$(( COMP_CWORD - 1 ));
                for ((i=0; i < ${#COMP_WORDS[@]} - 1; ++i ))
                do
                    COMP_WORDS[i]="${COMP_WORDS[i+1]}";
                done;
                unset COMP_WORDS[${#COMP_WORDS[@]}-1];
            else
                return;
            fi;
        fi
    }
    _renice () 
    { 
        local command cur curopt i;
        COMPREPLY=();
        cur=`_get_cword`;
        command=$1;
        i=0;
        while [ $i -le $COMP_CWORD -a ${#COMPREPLY[@]} -eq 0 ]; do
            curopt=${COMP_WORDS[COMP_CWORD-$i]};
            case "$curopt" in 
                -u)
                    COMPREPLY=($( compgen -u -- $cur ))
                ;;
                -g)
                    _pgids
                ;;
                -p | $command)
                    _pids
                ;;
            esac;
            i=$(( ++i ));
        done
    }
    _rl_enabled () 
    { 
        [[ "$( bind -v )" = *$1+([[:space:]])on* ]]
    }
    _rmmod () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        COMPREPLY=($( /sbin/lsmod | 		  awk '{if (NR != 1 && $1 ~ /^'$cur'/) print $1}' 2>/dev/null ));
        return 0
    }
    _root_command () 
    { 
        PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin _command $1 $2 $3
    }
    _route () 
    { 
        local cur prev;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        if [ "$prev" = dev ]; then
            COMPREPLY=($( ifconfig -a | sed -ne 's|^\('$cur'[^ ]*\).*$|\1|p' ));
            return 0;
        fi;
        COMPREPLY=($( compgen -W 'add del -host -net netmask metric mss \
    				   window irtt reject mod dyn reinstate dev \
    				   default gw' -- $cur ));
        COMPREPLY=($( echo " ${COMP_WORDS[@]}" | 		       (while read -d ' ' i; do
    			   [ "$i" == "" ] && continue
    			   # flatten array with spaces on either side,
    			   # otherwise we cannot grep on word
    			   # boundaries of first and last word
    			   COMPREPLY=" ${COMPREPLY[@]} "
    			   # remove word from list of completions
    			   COMPREPLY=( ${COMPREPLY/ $i / } )
    			done
    		       echo "${COMPREPLY[@]}")
    		  ));
        return 0
    }
    _rpm () 
    { 
        local cur prev ver nodig nosig;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        nodig="";
        nosig="";
        ver=$(rpm --version);
        ver=${ver##* };
        if [[ "$ver" > "4.0.4" ]]; then
            nodig="--nodigest";
        fi;
        if [[ "$ver" > "4.0.99" ]]; then
            nosig="--nosignature";
        fi;
        if [ $COMP_CWORD -eq 1 ]; then
            case "$cur" in 
                -b*)
                    COMPREPLY=($( compgen -W '-ba -bb -bc -bi -bl -bp -bs'				       -- $cur ))
                ;;
                -t*)
                    COMPREPLY=($( compgen -W '-ta -tb -tc -ti -tl -tp -ts'				       -- $cur ))
                ;;
                --*)
                    COMPREPLY=($( compgen -W '--help --version --initdb \
    			--checksig --recompile --rebuild --resign --addsign \
    			--rebuilddb --showrc --setperms --setugids --tarbuild \
    			--eval --install --upgrade --query --freshen --erase \
    			--verify --querytags --rmsource --rmspec --clean \
    			--import' -- $cur ))
                ;;
                *)
                    COMPREPLY=($( compgen -W '-b -e -F -i -q -t -U -V' 				       -- $cur ))
                ;;
            esac;
            return 0;
        fi;
        case "$prev" in 
            --@(@(db|exclude)path|prefix|relocate|root))
                _filedir -d;
                return 0
            ;;
            --eval)
                COMPREPLY=($( sed -ne 's|^\(%'${cur#\%}'[^ ''	'']*\).*$|\1|p' 			       /usr/lib/rpm/macros ));
                return 0
            ;;
            --pipe)
                COMPREPLY=($( compgen -c -- $cur ));
                return 0
            ;;
            --rcfile)
                _filedir;
                return 0
            ;;
            --specfile)
                _filedir spec;
                return 0
            ;;
            --whatprovides)
                if [[ "$cur" == */* ]]; then
                    _filedir;
                else
                    COMPREPLY=($( rpm -qa $nodig $nosig --queryformat 					'%{providename}\n' | grep "^$cur" ));
                fi;
                return 0
            ;;
            --whatrequires)
                COMPREPLY=($( rpm -qa $nodig $nosig --queryformat 				'%{requirename}\n' | grep "^$cur" ));
                return 0
            ;;
        esac;
        case "${COMP_WORDS[1]}" in 
            -@([iFU]*|-install|-freshen|-upgrade))
                if [[ "$cur" == -* ]]; then
                    COMPREPLY=($( compgen -W '--percent --force --test \
    			--replacepkgs --replacefiles --root --excludedocs \
    			--includedocs --noscripts --rcfile --ignorearch \
    			--dbpath --prefix --ignoreos --nodeps --allfiles \
    			--ftpproxy --ftpport --justdb --httpproxy --httpport \
    			--noorder --relocate --badreloc --notriggers \
    			--excludepath --ignoresize --oldpackage --define \
    			--eval --pipe --queryformat --repackage --nosuggests \
    			--nodigest --nosignature' -- $cur ));
                else
                    _filedir 'rpm';
                fi
            ;;
            -@(e|-erase))
                if [[ "$cur" == -* ]]; then
                    COMPREPLY=($( compgen -W '--allmatches --noscripts \
    			--notriggers --nodeps --test --repackage' -- $cur ));
                else
                    _rpm_installed_packages;
                fi
            ;;
            -@(q*|-query))
                if [ "${COMP_LINE#* -*([^ -])f}" != "$COMP_LINE" ]; then
                    if [[ "$cur" == -* ]]; then
                        COMPREPLY=($( compgen -W '--scripts --root \
    				--rcfile --requires --ftpport --ftpproxy \
    				--httpproxy --httpport --provides --triggers \
    				--dump --changelog --dbpath \
    				--last --filesbypkg \
    				--info --list --state \
    				--docfiles --configfiles --queryformat \
    				--conflicts --obsoletes \
    				--nodigest --nosignature \
    				--triggerscripts' -- $cur ));
                    else
                        _filedir;
                    fi;
                else
                    if [ "${COMP_LINE#* -*([^ -])g}" != "$COMP_LINE" ]; then
                        _rpm_groups;
                    else
                        if [ "${COMP_LINE#* -*([^ -])p}" != "$COMP_LINE" ]; then
                            if [[ "$cur" == -* ]]; then
                                COMPREPLY=($( compgen -W '--scripts --root \
    				--rcfile --whatprovides --whatrequires \
    				--requires --triggeredby --ftpport --ftpproxy \
    				--httpproxy --httpport --provides --triggers \
    				--dump --changelog --dbpath --filesbypkg \
    				--define --eval --pipe --showrc --info --list \
    				--state --docfiles --configfiles --queryformat\
    				--conflicts --obsoletes --nodigest \
    				--nosignature' -- $cur ));
                            else
                                _filedir 'rpm';
                            fi;
                        else
                            if [[ "$cur" == -* ]]; then
                                COMPREPLY=($( compgen -W '--scripts --root \
    				--rcfile --whatprovides --whatrequires \
    				--requires --triggeredby --ftpport --ftpproxy \
    				--httpproxy --httpport --provides --triggers \
    				--dump --changelog --dbpath --specfile \
    				--querybynumber --last --filesbypkg --define \
    				--eval --pipe --showrc --info --list --state \
    				--docfiles --configfiles --queryformat \
    				--conflicts --obsoletes --pkgid --hdrid \
    				--fileid --tid --nodigest --nosignature \
    				--triggerscripts' -- $cur ));
                            else
                                if [ "${COMP_LINE#* -*([^ -])a}" == "$COMP_LINE" ]; then
                                    _rpm_installed_packages;
                                fi;
                            fi;
                        fi;
                    fi;
                fi
            ;;
            -@(K*|-checksig))
                if [[ "$cur" == -* ]]; then
                    COMPREPLY=($( compgen -W '--nopgp --nogpg --nomd5 \
    					--nodigest --nosignature' -- $cur ));
                else
                    _filedir 'rpm';
                fi
            ;;
            -@([Vy]*|-verify))
                if [[ "$cur" == -* ]]; then
                    COMPREPLY=($( compgen -W '--root --rcfile --dbpath \
    			--nodeps --nogroup --nolinkto --nomode --nomtime \
    			--nordev --nouser --nofiles --noscripts --nomd5 \
    			--querytags --specfile --whatrequires --whatprovides \
    			--nodigest --nosignature' -- $cur ));
                else
                    if [ "${COMP_LINE#* -*([^ -])f}" != "$COMP_LINE" ]; then
                        _filedir;
                    else
                        if [ "${COMP_LINE#* -*([^ -])g}" != "$COMP_LINE" ]; then
                            _rpm_groups;
                        else
                            if [ "${COMP_LINE#* -*([^ -])p}" != "$COMP_LINE" ]; then
                                _filedir 'rpm';
                            else
                                _rpm_installed_packages;
                            fi;
                        fi;
                    fi;
                fi
            ;;
            -[bt]*)
                if [[ "$cur" == -* ]]; then
                    COMPREPLY=($( compgen -W '--short-circuit --timecheck \
    			--clean --rmsource --rmspec --test --sign --buildroot \
    			--target -- buildarch --buildos --nobuild --nodeps \
    			--nodirtokens' -- $cur ));
                else
                    if [[ ${COMP_WORDS[1]} == -b* ]]; then
                        _filedir 'spec';
                    else
                        _filedir '@(tgz|tar.@(gz|bz2))';
                    fi;
                fi
            ;;
            --re@(build|compile))
                if [[ "$cur" == -* ]]; then
                    COMPREPLY=($( compgen -W '--nodeps --rmsource \
    			  --rmspec --sign --nodirtokens --target' -- $cur ));
                else
                    _filedir '?(no)src.rpm';
                fi
            ;;
            --tarbuild)
                _filedir '@(tgz|tar.@(gz|bz2))'
            ;;
            --@(re|add)sign)
                _filedir 'rpm'
            ;;
            --set@(perms|gids))
                _rpm_installed_packages
            ;;
            --@(clean|rms@(ource|pec)))
                if [[ "$cur" == -* ]]; then
                    COMPREPLY=($( compgen -W '--clean --rmsource \
    					--rmspec' -- $cur ));
                else
                    _filedir 'spec';
                fi
            ;;
            --@(import|dbpath|root))
                if [[ "$cur" == -* ]]; then
                    COMPREPLY=($( compgen -W '--import --dbpath --root' 					-- $cur ));
                else
                    _filedir;
                fi
            ;;
        esac;
        return 0
    }
    _rpm_groups () 
    { 
        local IFS='	';
        cur=${cur%"\\"};
        COMPREPLY=($( rpm -qa $nodig $nosig --queryformat '%{group}\n' | 		       grep "^$cur" ));
        COMPREPLY=($( echo "${COMPREPLY[@]}" | sed 's/ /\\ /g' | tr '\n' '\t' ))
    }
    _rpm_installed_packages () 
    { 
        local ver nodig nosig;
        if [ -r /var/log/rpmpkgs -a /var/log/rpmpkgs -nt /var/lib/rpm/Packages ]; then
            COMPREPLY=($( sed -ne 		's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+.*\.rpm$|\1|p' 				/var/log/rpmpkgs ));
        else
            nodig="";
            nosig="";
            ver=$(rpm --version);
            ver=${ver##* };
            if [[ "$ver" > "4.0.4" ]]; then
                nodig="--nodigest";
            fi;
            if [[ "$ver" > "4.0.99" ]]; then
                nosig="--nosignature";
            fi;
            COMPREPLY=($( rpm -qa $nodig $nosig | sed -ne 		's|^\('$cur'.*\)-[0-9a-zA-Z._]\+-[0-9a-z.@]\+$|\1|p' ));
        fi
    }
    _rsync () 
    { 
        local cur prev shell i userhost path;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        _expand || return 0;
        case "$prev" in 
            --@(config|password-file|include-from|exclude-from))
                _filedir;
                return 0
            ;;
            -@(T|-temp-dir|-compare-dest))
                _filedir -d;
                return 0
            ;;
            -@(e|-rsh))
                COMPREPLY=($( compgen -W 'rsh ssh' -- $cur ));
                return 0
            ;;
        esac;
        case "$cur" in 
            -*)
                COMPREPLY=($( compgen -W '-v -q  -c -a -r -R -b -u -l -L -H \
    				-p -o -g -D -t -S -n -W -x -B -e -C -I -T -P \
    				-z -h -4 -6 --verbose --quiet --checksum \
    				--archive --recursive --relative --backup \
    				--backup-dir --suffix= --update --links \
    				--copy-links --copy-unsafe-links --safe-links \
    				--hard-links --perms --owner --group --devices\
    				--times --sparse --dry-run --whole-file \
    				--no-whole-file --one-file-system \
    				--block-size= --rsh= --rsync-path= \
    				--cvs-exclude --existing --ignore-existing \
    				--delete --delete-excluded --delete-after \
    				--ignore-errors --max-delete= --partial \
    				--force --numeric-ids --timeout= \
    				--ignore-times --size-only --modify-window= \
    				--temp-dir= --compare-dest= --compress \
    				--exclude= --exclude-from= --include= \
    				--include-from= --version --daemon --no-detach\
    				--address= --config= --port= --blocking-io \
    				--no-blocking-io --stats --progress \
    				--log-format= --password-file= --bwlimit= \
    				--write-batch= --read-batch= --help' -- $cur ))
            ;;
            *:*)
                shell=rsh;
                for ((i=1; i < COMP_CWORD; i++ ))
                do
                    if [[ "${COMP_WORDS[i]}" == -@(e|-rsh) ]]; then
                        shell=${COMP_WORDS[i+1]};
                        break;
                    fi;
                done;
                if [[ "$shell" == ssh ]]; then
                    cur=${cur/\\:/:};
                    userhost=${cur%%?(\\):*};
                    path=${cur#*:};
                    path=${path//\\\\\\\\ / };
                    if [ -z "$path" ]; then
                        path=$(ssh -o 'Batchmode yes' 					$userhost pwd 2>/dev/null);
                    fi;
                    COMPREPLY=($( ssh -o 'Batchmode yes' $userhost 				command ls -aF1d "$path*" 2>/dev/null | 				sed -e 's/ /\\\\\\\ /g' -e 's/[*@|=]$//g' 				-e 's/[^\/]$/& /g' ));
                fi
            ;;
            *)
                _known_hosts -c -a;
                _filedir
            ;;
        esac;
        return 0
    }
    _scp () 
    { 
        local cur userhost path;
        COMPREPLY=();
        cur=`_get_cword ":"`;
        _expand || return 0;
        if [[ "$cur" == *:* ]]; then
            local IFS='	
    ';
            cur=${cur/\\:/:};
            userhost=${cur%%?(\\):*};
            path=${cur#*:};
            path=${path//\\\\\\\\ / };
            if [ -z "$path" ]; then
                path=$(ssh -o 'Batchmode yes' $userhost pwd 2>/dev/null);
            fi;
            COMPREPLY=($( ssh -o 'Batchmode yes' $userhost 			       command ls -aF1d "$path*" 2>/dev/null | 			       sed -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\\\\\\\\\&/g" 				   -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ));
            return 0;
        fi;
        [[ "$cur" == */* ]] || _known_hosts -c -a;
        local IFS='	
    ';
        COMPREPLY=("${COMPREPLY[@]}" $( command ls -aF1d $cur* 			    2>/dev/null | sed 			    -e "s/[][(){}<>\",:;^&!$&=?\`|\\ ']/\\\\&/g" 			    -e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' ));
        return 0
    }
    _screen () 
    { 
        local cur prev preprev;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        [ "$COMP_CWORD" -ge 2 ] && preprev=${COMP_WORDS[COMP_CWORD-2]};
        if [ "$preprev" = "-d" -o "$preprev" = "-D" -a "$prev" = "-r" -o "$prev" = "-R" ]; then
            COMPREPLY=($( command screen -ls | 				sed -ne 's|^[''	'']\+\('$cur'[0-9]\+\.[^''	'']\+\).*$|\1|p' ));
        else
            case "$prev" in 
                -[rR])
                    COMPREPLY=($( command screen -ls | 					sed -ne 's|^[''	'']\+\('$cur'[0-9]\+\.[^''	'']\+\).*Detached.*$|\1|p' ))
                ;;
                -[dDx])
                    COMPREPLY=($( command screen -ls | 					sed -ne 's|^[''	'']\+\('$cur'[0-9]\+\.[^''	'']\+\).*Attached.*$|\1|p' ))
                ;;
                -s)
                    COMPREPLY=($( grep ^${cur:-[^#]} /etc/shells ))
                ;;
                *)
    
                ;;
            esac;
        fi;
        return 0
    }
    _service () 
    { 
        local cur sysvdir;
        COMPREPLY=();
        prev=${COMP_WORDS[COMP_CWORD-1]};
        cur=`_get_cword`;
        [[ ${COMP_WORDS[0]} != @(*init.d/!(functions|~)|service) ]] && return 0;
        [ $COMP_CWORD -gt 2 ] && return 0;
        [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d;
        if [[ $COMP_CWORD -eq 1 ]] && [[ $prev == "service" ]]; then
            _services;
        else
            COMPREPLY=($( compgen -W '`sed -ne "y/|/ /; \
    				s/^.*Usage.*{\(.*\)}.*$/\1/p" \
    				$sysvdir/${prev##*/} 2>/dev/null`' -- $cur ));
        fi;
        return 0
    }
    _services () 
    { 
        local sysvdir famdir;
        [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d;
        famdir=/etc/xinetd.d;
        COMPREPLY=($( builtin echo $sysvdir/!(*.rpmsave|*.rpmorig|*~|functions)));
        if [ -d $famdir ]; then
            COMPREPLY=("${COMPREPLY[@]}" $( builtin echo $famdir/!(*.rpmsave|*.rpmorig|*~)));
        fi;
        COMPREPLY=($( compgen -W '${COMPREPLY[@]#@($sysvdir|$famdir)/}' -- $cur ))
    }
    _signals () 
    { 
        local i;
        COMPREPLY=($( compgen -A signal SIG${cur#-} ));
        for ((i=0; i < ${#COMPREPLY[@]}; i++ ))
        do
            COMPREPLY[i]=-${COMPREPLY[i]#SIG};
        done
    }
    _ssh () 
    { 
        local cur prev;
        local -a config;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case "$prev" in 
            -*c)
                COMPREPLY=($( compgen -W 'blowfish 3des 3des-cbc blowfish-cbc \
    			   arcfour cast128-cbc' -- $cur ))
            ;;
            -*i)
                _filedir
            ;;
            -*l)
                COMPREPLY=($( compgen -u -- $cur ))
            ;;
            *)
                _known_hosts -a;
                [ $COMP_CWORD -eq 1 ] || COMPREPLY=("${COMPREPLY[@]}" $( compgen -c -- $cur ))
            ;;
        esac;
        return 0
    }
    _sysctl () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        COMPREPLY=($( compgen -W "$(sysctl -N -a 2>/dev/null)" -- $cur ));
        return 0
    }
    _tar () 
    { 
        local cur ext regex tar untar;
        COMPREPLY=();
        cur=`_get_cword`;
        if [ $COMP_CWORD -eq 1 ]; then
            COMPREPLY=($( compgen -W 'c t x u r d A' -- $cur ));
            return 0;
        fi;
        case "${COMP_WORDS[1]}" in 
            ?(-)[cr]*f)
                _filedir;
                return 0
            ;;
            +([^IZzjy])f)
                ext='t@(ar?(.@(Z|gz|bz?(2)))|gz|bz?(2))';
                regex='t\(ar\(\.\(Z\|gz\|bz2\?\)\)\?\|gz\|bz2\?\)'
            ;;
            *[Zz]*f)
                ext='t?(ar.)@(gz|Z)';
                regex='t\(ar\.\)\?\(gz\|Z\)'
            ;;
            *[Ijy]*f)
                ext='t?(ar.)bz?(2)';
                regex='t\(ar\.\)\?bz2\?'
            ;;
            *)
                _filedir;
                return 0
            ;;
        esac;
        if [[ "$COMP_LINE" == *$ext' ' ]]; then
            tar=$( echo "$COMP_LINE" | 			sed -e 's/^.* \([^ ]*'$regex'\) .*$/\1/' );
            untar=t${COMP_WORDS[1]//[^Izjyf]/};
            COMPREPLY=($( compgen -W "$( echo $( tar $untar $tar 				2>/dev/null ) )" -- "$cur" ));
            return 0;
        fi;
        _filedir "$ext";
        return 0
    }
    _tcpdump () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case "$prev" in 
            -@(r|w|F))
                _filedir;
                return 0
            ;;
            -i)
                _available_interfaces -a;
                return 0
            ;;
        esac;
        if [[ "$cur" == -* ]]; then
            COMPREPLY=($( compgen -W '-a -d -e -f -l -n -N -O -p \
    			-q -R -S -t -u -v -x -C -F -i -m -r -s -T -w \
    			-E' -- $cur ));
        fi
    }
    _uids () 
    { 
        if type getent >&/dev/null; then
            COMPREPLY=($( getent passwd | 			    awk -F: '{if ($3 ~ /^'$cur'/) print $3}' ));
        else
            if type perl >&/dev/null; then
                COMPREPLY=($( compgen -W '$( perl -e '"'"'while (($uid) = (getpwent)[2]) { print $uid . "\n" }'"'"' )' -- $cur ));
            else
                COMPREPLY=($( awk 'BEGIN {FS=":"} {if ($3 ~ /^'$cur'/) print $3}'			    /etc/passwd ));
            fi;
        fi
    }
    _umount () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        OLDIFS="$IFS";
        IFS="\n";
        COMPREPLY=($( compgen -W '$( mount | cut -d" " -f 3 )' -- $cur ));
        IFS="$OLDIFS";
        return 0
    }
    _update_alternatives () 
    { 
        local cur prev mode args i;
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case "$prev" in 
            --@(altdir|admindir))
                _filedir -d;
                return 0
            ;;
            --@(help|version))
                return 0
            ;;
        esac;
        for ((i=1; i < COMP_CWORD; i++ ))
        do
            if [[ "${COMP_WORDS[i]}" == --@(install|remove|auto|display|config|remove-all) ]]; then
                mode=${COMP_WORDS[i]};
                args=$(($COMP_CWORD - i));
                break;
            fi;
        done;
        case $mode in 
            --install)
                case $args in 
                    1)
                        _filedir
                    ;;
                    2)
                        installed_alternatives
                    ;;
                    3)
                        _filedir
                    ;;
                esac
            ;;
            --remove)
                case $args in 
                    1)
                        installed_alternatives
                    ;;
                    2)
                        _filedir
                    ;;
                esac
            ;;
            --auto)
                installed_alternatives
            ;;
            --remove-all)
                installed_alternatives
            ;;
            --display)
                installed_alternatives
            ;;
            --config)
                installed_alternatives
            ;;
            *)
                COMPREPLY=($( compgen -W '--verbose --quiet --help --version \
    			       --altdir --admindir' -- $cur ) $( compgen -W '--install --remove --auto --display \
    			       --config' -- $cur ))
            ;;
        esac
    }
    _update_rc_d () 
    { 
        local cur prev sysvdir services options valid_options;
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        [ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d;
        services=($(echo $sysvdir/!(README*|*.sh|*.dpkg*|*.rpm*)));
        services=(${services[@]#$sysvdir/});
        options=(-f -n);
        if [[ $COMP_CWORD -eq 1 || "$prev" == -* ]]; then
            valid_options=($( 	    echo "${COMP_WORDS[@]} ${options[@]}" 	    | tr " " "\n" 	    | sed -ne "/$( echo "${options[@]}" | sed "s/ /\\|/g" )/p" 	    | sort | uniq -u 	    ));
            COMPREPLY=($( compgen -W '${options[@]} ${services[@]}' 	    -X '$( echo ${COMP_WORDS[@]} | tr " " "|" )' -- $cur ));
        else
            if [[ "$prev" == ?($( echo ${services[@]} | tr " " "|" )) ]]; then
                COMPREPLY=($( compgen -W 'remove defaults start stop' -- $cur ));
            else
                if [[ "$prev" == defaults && "$cur" == [0-9] ]]; then
                    COMPREPLY=(0 1 2 3 4 5 6 7 8 9);
                else
                    if [[ "$prev" == defaults && "$cur" == [sk]?([0-9]) ]]; then
                        COMPREPLY=(0 1 2 3 4 5 6 7 8 9);
                    else
                        if [[ "$prev" == defaults && -z "$cur" ]]; then
                            COMPREPLY=(0 1 2 3 4 5 6 7 8 9 s k);
                        else
                            if [[ "$prev" == ?(start|stop) ]]; then
                                if [[ "$cur" == [0-9] || -z "$cur" ]]; then
                                    COMPREPLY=(0 1 2 3 4 5 6 7 8 9);
                                else
                                    if [[ "$cur" == [0-9][0-9] ]]; then
                                        COMPREPLY=($cur);
                                    else
                                        COMPREPLY=();
                                    fi;
                                fi;
                            else
                                if [[ "$prev" == ?([0-9][0-9]|[0-6S]) ]]; then
                                    if [[ -z "$cur" ]]; then
                                        if [[ $prev == [0-9][0-9] ]]; then
                                            COMPREPLY=(0 1 2 3 4 5 6 S);
                                        else
                                            COMPREPLY=(0 1 2 3 4 5 6 S .);
                                        fi;
                                    else
                                        if [[ "$cur" == [0-6S.] ]]; then
                                            COMPREPLY=($cur);
                                        else
                                            COMPREPLY=();
                                        fi;
                                    fi;
                                else
                                    if [[ "$prev" == "." ]]; then
                                        COMPREPLY=($(compgen -W "start stop" -- $cur));
                                    else
                                        COMPREPLY=();
                                    fi;
                                fi;
                            fi;
                        fi;
                    fi;
                fi;
            fi;
        fi;
        return 0
    }
    _user_at_host () 
    { 
        local cur;
        COMPREPLY=();
        cur=`_get_cword`;
        if [[ $cur == *@* ]]; then
            _known_hosts;
        else
            COMPREPLY=($( compgen -u -- "$cur" ));
        fi;
        return 0
    }
    _usergroup () 
    { 
        local IFS='
    ';
        cur=${cur//\\\\ / };
        if [[ $cur = *@(\\:|.)* ]] && [ -n "$bash205" ]; then
            user=${cur%%*([^:.])};
            COMPREPLY=($(compgen -P ${user/\\\\} -g -- ${cur##*[.:]}));
        else
            if [[ $cur = *:* ]] && [ -n "$bash205" ]; then
                COMPREPLY=($( compgen -g -- ${cur##*[.:]} ));
            else
                COMPREPLY=($( compgen -S : -u -- $cur ));
            fi;
        fi
    }
    _wvdial () 
    { 
        local cur prev config i IFS='	
    ';
        COMPREPLY=();
        cur=`_get_cword`;
        prev=${COMP_WORDS[COMP_CWORD-1]};
        case $prev in 
            --config)
                _filedir;
                return 0
            ;;
        esac;
        case $cur in 
            -*)
                COMPREPLY=($( compgen -W '--config --chat \
    				--remotename --help --version --no-syslog' 				-- $cur ))
            ;;
            *)
                config="/etc/wvdial.conf"'	'"$HOME/.wvdialrc";
                for ((i=1; i < COMP_CWORD; i++ ))
                do
                    if [[ "${COMP_WORDS[i]}" == "--config" ]]; then
                        config=${COMP_WORDS[i+1]};
                        break;
                    fi;
                done;
                COMPREPLY=($( sed -ne 				    "s|^\[Dialer \($cur.*\)\]$|\1|p" 				    $config 2>/dev/null |grep -v '^Defaults$'));
                COMPREPLY=${COMPREPLY// /\\ }
            ;;
        esac
    }
    command_not_found_handle () 
    { 
        if [ -x /usr/lib/command-not-found ]; then
            /usr/bin/python /usr/lib/command-not-found -- $1;
            return $?;
        else
            return 127;
        fi
    }
    dequote () 
    { 
        eval echo "$1"
    }
    get_entries () 
    { 
        local IFS='
    ';
        [ -r ${prefix:-}CVS/Entries ] && entries=$(cut -d/ -f2 -s ${prefix:-}CVS/Entries)
    }
    get_modules () 
    { 
        if [ -n "$prefix" ]; then
            COMPREPLY=($( command ls -d ${cvsroot}/${prefix}/!(CVSROOT) ));
        else
            COMPREPLY=($( command ls -d ${cvsroot}/!(CVSROOT) ));
        fi
    }
    installed_alternatives () 
    { 
        local admindir;
        for i in alternatives dpkg/alternatives rpm/alternatives;
        do
            [ -d /var/lib/$i ] && admindir=/var/lib/$i && break;
        done;
        for ((i=1; i < COMP_CWORD; i++ ))
        do
            if [[ "${COMP_WORDS[i]}" == --admindir ]]; then
                admindir=${COMP_WORDS[i+1]};
                break;
            fi;
        done;
        COMPREPLY=($( command ls $admindir | grep "^$cur" ))
    }
    quote () 
    { 
        echo \'${1//\'/\'\\\'\'}\'
    }
    quote_readline () 
    { 
        local t="${1//\\/\\\\}";
        echo \'${t//\'/\'\\\'\'}\'
    }
    set_prefix () 
    { 
        [ -z ${prefix:-} ] || prefix=${cur%/*}/;
        [ -r ${prefix:-}CVS/Entries ] || prefix=""
    }

  2. #2
    Linux Newbie
    Join Date
    Feb 2009
    Location
    Third ring of Pergatory
    Posts
    199
    You can pipe "set" into more
    $> set | more
    and capture all the lines or you can redirect it from stdout to a file like this
    $> set > env.txt
    which will give you an easy lookup via grep, egrep, etc. It will also let you see if any environ vars have changed with the installation of new packages or why a particular package can't find it's oh so precious libs and refuses to work.

  3. #3
    Linux Newbie
    Join Date
    Feb 2009
    Location
    Third ring of Pergatory
    Posts
    199
    sorry I missed your last two questions.

    1) What is the limit on the number of lines that a terminal can access (limit of lines we can reach by scrolling)?

    I think the terminal resource file sets the amount of data held in the buffer.

    2) What does the rest of the output do (containing lots of loops and other stuff)? (Rather than a very technical answer, a hand-waving general answer will be more illuminating.)

    You got loops and stuff?
    Count yourself as lucky and stop waiving them around or everybody will want some.

  4. #4
    Just Joined!
    Join Date
    Oct 2008
    Location
    Bhubaneswar, Bangalore, INDIA
    Posts
    22
    Thanks a lot.

    As I had mentioned, redirecting the output to a text file was the only way I had been able to read the 1st few lines. But I didn't know about "piping" into 'more'.

    You got loops and stuff?
    Count yourself as lucky and stop waiving them around or everybody will want some.


    I somehow have a feeling that this was a sarcastic remark. Correct me if I am wrong.

    But my 2nd question still remains unanswered. The book from which I was studying Bash shell scripting also has the full output of the 'set' command and there is no other output other than the ENV variables list.

    Then why do I get these "loops and stuff".

    I have already posted all the output in my 1st post in this thread. Would you mind going through?

  5. #5
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.
    Quote Originally Posted by baltana View Post
    ... Then why do I get these "loops and stuff" ...
    Running a Google search on bash set yields from the second hit:
    4.3 The Set Builtin

    This builtin is so complicated that it deserves its own section.

    set

    set [--abefhkmnptuvxBCHP] [-o option] [argument ...]

    If no options or arguments are supplied, set displays the names and values of all shell variables and functions, sorted according to the current locale, in a format that may be reused as input for setting or resetting the currently-set variables. Read-only variables cannot be reset. In posix mode, only shell variables are listed.

    -- excerpt from The Set Builtin - Bash Reference Manual
    So you are seeing listings of functions as well as your variables.

    Best wishes ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  6. #6
    Just Joined!
    Join Date
    Oct 2008
    Location
    Bhubaneswar, Bangalore, INDIA
    Posts
    22
    Thanks.

    Its sad that the shell builtins have no man pages.
    Surprisingly, the thought of googling for online man pages never crossed my mind.

  7. #7
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    There is a man page for bash, and there is also a help command for recent versions of bash:
    Code:
    $ bash --version
    GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu)
    Copyright (C) 2007 Free Software Foundation, Inc.
    $ help set
    set: set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
    ( ... )
    It is not as detailed as the reference manual. Some books may describe builtin set more completely than others ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  8. #8
    Linux Newbie
    Join Date
    Feb 2009
    Location
    Third ring of Pergatory
    Posts
    199
    Quote Originally Posted by baltana View Post
    I somehow have a feeling that this was a sarcastic remark. Correct me if I am wrong.
    No, your probably better at this than I am, I was just kidding around, I was stumped by your request for a non-technical answer.
    Listen to DRL , he's a much more serious fellow, they have to grease his ears to get his giant brain through doorways.(I hereby apologize to him for saying that.)

  9. #9
    Just Joined!
    Join Date
    Oct 2008
    Location
    Bhubaneswar, Bangalore, INDIA
    Posts
    22
    Quote Originally Posted by dijetlo View Post
    No, your probably better at this than I am, I was just kidding around, I was stumped by your request for a non-technical answer.
    Listen to DRL , he's a much more serious fellow, they have to grease his ears to get his giant brain through doorways.(I hereby apologize to him for saying that.)
    I asked for a non-technical answer because a technical answer would have been of little use and beyond my comprehension in my present state of knowledge of Linux.

    I actually got a non-technical answer. Did you notice that?

    It lists the functions too. That's what I wanted to know. I didn't want somebody to go on and describe what those loops inside the functions do.

    So did you correct me or not???

  10. #10
    Linux Newbie
    Join Date
    Feb 2009
    Location
    Third ring of Pergatory
    Posts
    199
    Quote Originally Posted by baltana View Post
    I actually got a non-technical answer. Did you notice that?
    I'm pretty oblivious....
    Quote Originally Posted by baltana View Post
    So did you correct me or not???
    Wait a minute, I've got a headache and that indicates at some level, I'm thinking.....I better answer fast, because thinking makes me sleepy...No, I wasn't being sarcastic because sarcasm suggests some ill will towards you or your question , I was just being a smart ass, and lazy. If you knew me better, you wouldn't be surprised...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...