Ubuntu Forums Archive Viewer

bash-completion problems

Archived thread 1494962 from Maverick Meerkat Testing and Discussion (CLOSED). Markdown source: Maverick_Meerkat_Testing_and_Discussion_(CLOSED)/thread_1494962_bash-completion_problems.md

Original URL About this archive
#1

On start of gnome-terminal I get:`` bash: /etc/bash_completion.d/apt: line 32: syntax error near unexpected token ;' bash: /etc/bash_completion.d/apt: line 32: 2> /dev/null ); $( apt-cache --no-generate pkgnames "lib$cur" \' bash: /etc/bash_completion.d/apt: line 33: syntax error near unexpected token )' bash: /etc/bash_completion.d/apt: line 33: ` 2> /dev/null); )

I'll try to see what's wrong but...
#2

zika said: On start of gnome-terminal I get:```

bash: /etc/bash_completion.d/apt: line 32: syntax error near unexpected token ;' bash: /etc/bash_completion.d/apt: line 32: 2> /dev/null ); $( apt-cache --no-generate pkgnames "lib$cur" \' bash: /etc/bash_completion.d/apt: line 33: syntax error near unexpected token )' bash: /etc/bash_completion.d/apt: line 33: 2> /dev/null); )

I'll try to see what's wrong but...

Confirm. Exact same problem...
Some fun in maverick now.
#3

getting this too

#4

****Removing the two ";" seems to work, but I'm not feeling very comfortable doing this.

#5

Yes, first came the gnome-terminal removal, then after I fixed that I now have this bash error as well.

#6

it was the upgrade to bash-completion 1.1.1-3ubuntu3 that did it I started gnome-terminal no errors then upgraded and started it again and the errors are there . anyone bug it yet ?

#7

ronacc said: anyone bug it yet ?

The bad patch points to this bug: https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/546794

#8

looks like they're on it last post says they are going to revert the patch .

#9

I've got some spare time on my hands, played with offending file and got the results I've wrote on launchpad, in that bug report... My opinion is that, now with two ";" removed it works as it is supposed to work, even though I think that, now, without ";" syntax is not 20/20...

#10

Why not? The statement in question seems to be an array and ( AAA BBB CCC ) is a perfectly valid array declaration syntax?

#11

Reiger said: Why not? The statement in question seems to be an array and ( AAA BBB CCC ) is a perfectly valid array declaration syntax?Then, we are OK just with removing 2 ";"...

#12

I removed them, but I'm left with "enexpected end of file" which I can't seem to do anything about. Everything works though, it's just that it's plain ugly when opening the CLI.

#13

xeizo said: I removed them, but I'm left with "enexpected end of file" which I can't seem to do anything about. Everything works though, it's just that it's plain ugly when opening the CLI.

Well you must have removed something more than or different from those two semi-colons in the outer parentheses (on line 33). That error means there's an opening statement somewhere but not a corresponding closing statement (e.g. opening parenthesis without matching closing parenthesis).

My version of /etc/bash_completion.d/apt is this:


# Debian apt-get(8) completion.

have apt-get &&
_apt_get()
{
    local cur prev special i
/etc/bas
    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|autoremove|purge|source|build-dep) ]]; then
            special=${COMP_WORDS[i]}
        fi
    done

    if [ -n "$special" ]; then
        case $special in
            remove|autoremove|purge)
                if [ -f /etc/debian_version ]; then
                    # Debian system
                    COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
                else
                    # assume RPM based
                    _rpm_installed_packages
                fi
                return 0
                ;;
            *)
                COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
                    2> /dev/null ) $( apt-cache --no-generate pkgnames "lib$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 --no-install-recommends --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
} &&
complete -F _apt_get $filenames apt-get

# Debian apt-cache(8) completion.
#
have apt-cache &&
_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|madison|policy|rdepends|show?(pkg|src|)) ]]; then
            special=${COMP_WORDS[i]}
        fi
        done
    fi


    if [ -n "$special" ]; then
        case $special in
        add)
            _filedir
            return 0
            ;;

        showsrc)
            COMPREPLY=( $( apt-cache dumpavail | \
                            grep "^Source: $cur" | sort | \
                            uniq | cut -f2 -d" " ) )
            return 0
            ;;

        *)
            COMPREPLY=( $( apt-cache --no-generate 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 --installed' -- "$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
} &&
complete -F _apt_cache $filenames apt-cache

# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh

#14

Reiger said: Well you must have removed something more than or different from those two semi-colons in the outer parentheses (on line 33).

That error means there's an opening statement somewhere but not a corresponding closing statement (e.g. opening parenthesis without matching closing parenthesis).

My version of /etc/bash_completion.d/apt is this:


# Debian apt-get(8) completion.

have apt-get &&
_apt_get()
{
    local cur prev special i
/etc/bas
    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|autoremove|purge|source|build-dep) ]]; then
            special=${COMP_WORDS[i]}
        fi
    done

    if [ -n "$special" ]; then
        case $special in
            remove|autoremove|purge)
                if [ -f /etc/debian_version ]; then
                    # Debian system
                    COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
                else
                    # assume RPM based
                    _rpm_installed_packages
                fi
                return 0
                ;;
            *)
                COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
                    2> /dev/null ) $( apt-cache --no-generate pkgnames "lib$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 --no-install-recommends --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
} &&
complete -F _apt_get $filenames apt-get

# Debian apt-cache(8) completion.
#
have apt-cache &&
_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|madison|policy|rdepends|show?(pkg|src|)) ]]; then
            special=${COMP_WORDS[i]}
        fi
        done
    fi


    if [ -n "$special" ]; then
        case $special in
        add)
            _filedir
            return 0
            ;;

        showsrc)
            COMPREPLY=( $( apt-cache dumpavail | \
                            grep "^Source: $cur" | sort | \
                            uniq | cut -f2 -d" " ) )
            return 0
            ;;

        *)
            COMPREPLY=( $( apt-cache --no-generate 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 --installed' -- "$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
} &&
complete -F _apt_cache $filenames apt-cache

# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh

I renamed /etc/bash_completion.d/apt and cut and pasted your version there still getting

bash: /etc/bash_completion.d/apto: line 32: syntax error near unexpected token `;'
bash: /etc/bash_completion.d/apto: line 32: `                    2> /dev/null ); $( apt-cache --no-generate pkgnames "lib$cur" \'
bash: /etc/bash_completion.d/apto: line 33: syntax error near unexpected token `)'
bash: /etc/bash_completion.d/apto: line 33: `                    2> /dev/null); )'
ron@ron-desktop2:~$ 

note I even tried rebooting to see maybe it loaded that at startup .

#15

ronacc said: I renamed /etc/bash_completion.d/apt and cut and pasted your version there

still getting

bash: /etc/bash_completion.d/apto: line 32: syntax error near unexpected token `;'
bash: /etc/bash_completion.d/apto: line 32: `                    2> /dev/null ); $( apt-cache --no-generate pkgnames "lib$cur" \'
bash: /etc/bash_completion.d/apto: line 33: syntax error near unexpected token `)'
bash: /etc/bash_completion.d/apto: line 33: `                    2> /dev/null); )'
ron@ron-desktop2:~$ 

note I even tried rebooting to see maybe it loaded that at startup .

Hmm, you left the renamed file in /etc/bash_completion.d/ everything in that folder will be read. Move the file "apto" somewhere else.

#16

Here is the file I've got after aforementioned surgery... .txt is just to bypass filter...

#17

vigstrom said: Hmm, you left the renamed file in /etc/bash_completion.d/

everything in that folder will be read. Move the file "apto" somewhere else.

thanks I didn't notice that it was reading apto I'll move it .

@ zika I'll also try the file you posted thanks .

Got to run off right now I'll report back later .

#18

ronacc said: @ zika I'll also try the file you posted thanks.Do not follow me, I do not know, either, the correct path through this wood... :)

#19

not to worry , I backup a file before I edit it . Thats where the apto referenced above came from , o for original :D besides I have lots of practice recovering from self inflicted wounds , see my sig :lolflag:

#20

@ Reiger; I probably did, your file works fine! Thanks!

#21

both Zika's and Reiger's apt's work , they are identical as far as I can tell .

#22

ronacc said: not to worry , I backup a file before I edit it . Thats where the apto referenced above came from , o for original :D besides I have lots of practice recovering from self inflicted wounds , see my sig :lolflag:I do quote Your sig, at least, a couple of dozen of times during each and every week... :)

#23

Is anyone else getting this when invoking a terminal cli?

bash: /etc/bash_completion.d/apt: line 32: syntax error near unexpected token `;'
bash: /etc/bash_completion.d/apt: line 32: `                    2> /dev/null ); $( apt-cache --no-generate pkgnames "lib$cur" \'
bash: /etc/bash_completion.d/apt: line 33: syntax error near unexpected token `)'
bash: /etc/bash_completion.d/apt: line 33: `                    2> /dev/null); )'
xxxxxx@emachines-laptop:~$
#24

I am also getting this

#25
#26

I've attached a patch that should fix the problem, just download it and run this:

sudo patch /etc/bash_completion.d/apt **/path/to/**apt_completion.txt

*(it's a [FONT="Courier New"].txt[/FONT] to bypass the file filter)*

#27

Penguin Guy said: I've attached a patch that should fix the problem, just download it and run this:

sudo patch /etc/bash_completion.d/apt **/path/to/**apt_completion.txt

*(it's a [FONT="Courier New"].txt[/FONT] to bypass the file filter)*I was curious. After using Your patch I get, again`` bash: /etc/bash_completion.d/apt: line 34: syntax error near unexpected token ;;' bash: /etc/bash_completion.d/apt: line 34: ;;' bash: /etc/bash_completion.d/apt: line 35: syntax error near unexpected token esac' bash: /etc/bash_completion.d/apt: line 35: ` esac'

Maybe it would be good idea if You could send correct /etc/bash_comletion.d/apt to see what does correct file look like...
#28

Taking some time to look at the bug and file itself, maybe file attached is a better bet...

#29

Reiger said: Well you must have removed something more than or different from those two semi-colons in the outer parentheses (on line 33).

That error means there's an opening statement somewhere but not a corresponding closing statement (e.g. opening parenthesis without matching closing parenthesis).

My version of /etc/bash_completion.d/apt is this:


# Debian apt-get(8) completion.

have apt-get &&
_apt_get()
{
    local cur prev special i
/etc/bas
    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|autoremove|purge|source|build-dep) ]]; then
            special=${COMP_WORDS[i]}
        fi
    done

    if [ -n "$special" ]; then
        case $special in
            remove|autoremove|purge)
                if [ -f /etc/debian_version ]; then
                    # Debian system
                    COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
                else
                    # assume RPM based
                    _rpm_installed_packages
                fi
                return 0
                ;;
            *)
                COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
                    2> /dev/null ) $( apt-cache --no-generate pkgnames "lib$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 --no-install-recommends --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
} &&
complete -F _apt_get $filenames apt-get

# Debian apt-cache(8) completion.
#
have apt-cache &&
_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|madison|policy|rdepends|show?(pkg|src|)) ]]; then
            special=${COMP_WORDS[i]}
        fi
        done
    fi


    if [ -n "$special" ]; then
        case $special in
        add)
            _filedir
            return 0
            ;;

        showsrc)
            COMPREPLY=( $( apt-cache dumpavail | \
                            grep "^Source: $cur" | sort | \
                            uniq | cut -f2 -d" " ) )
            return 0
            ;;

        *)
            COMPREPLY=( $( apt-cache --no-generate 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 --installed' -- "$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
} &&
complete -F _apt_cache $filenames apt-cache

# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh

I pasted the contents of your file OVER my old apt file and it seems to work just fine now. Thanks.

#30

zika said: "Solved" at http://ubuntuforums.org/showthread.php?t=1494962

Thanks, this worked for me.

#31

Reiger said: Well you must have removed something more than or different from those two semi-colons in the outer parentheses (on line 33).

That error means there's an opening statement somewhere but not a corresponding closing statement (e.g. opening parenthesis without matching closing parenthesis).

My version of /etc/bash_completion.d/apt is this:


# Debian apt-get(8) completion.

have apt-get &&
_apt_get()
{
    local cur prev special i
[COLOR="Red"]/etc/bas[/COLOR]
    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|autoremove|purge|source|build-dep) ]]; then
            special=${COMP_WORDS[i]}
        fi
    done

    if [ -n "$special" ]; then
        case $special in
            remove|autoremove|purge)
                if [ -f /etc/debian_version ]; then
                    # Debian system
                    COMPREPLY=( $( _comp_dpkg_installed_packages $cur ) )
                else
                    # assume RPM based
                    _rpm_installed_packages
                fi
                return 0
                ;;
            *)
                COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
                    2> /dev/null ) $( apt-cache --no-generate pkgnames "lib$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 --no-install-recommends --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
} &&
complete -F _apt_get $filenames apt-get

# Debian apt-cache(8) completion.
#
have apt-cache &&
_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|madison|policy|rdepends|show?(pkg|src|)) ]]; then
            special=${COMP_WORDS[i]}
        fi
        done
    fi


    if [ -n "$special" ]; then
        case $special in
        add)
            _filedir
            return 0
            ;;

        showsrc)
            COMPREPLY=( $( apt-cache dumpavail | \
                            grep "^Source: $cur" | sort | \
                            uniq | cut -f2 -d" " ) )
            return 0
            ;;

        *)
            COMPREPLY=( $( apt-cache --no-generate 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 --installed' -- "$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
} &&
complete -F _apt_cache $filenames apt-cache

# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh

Please, do not think that I'm trying to compete, I'm just making a joke...

#32

@zika

I've attached my corrected version, but here's the relevant part:


                ;;
            *)
                COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
                    2> /dev/null )
                return 0
                ;;
        esac

I'd also be interested to see your unpatched version of the file.

EDIT: Oops, I think I might have posted the wrong file.

#33

Penguin Guy said: @zika

I've attached my corrected version, but here's the relevant part:


                ;;
            *)
                COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
                    2> /dev/null )
                return 0
                ;;
        esac

I'd also be interested to see your unpatched version of the file.I think this is the one, but I am not completely sure if this is not changed a bit from the "real" original... The "main" discussion about this is in the "other" thread, given above in my message...

#34

zika said: I think this is the one, but I am not completely sure if this is not changed a bit from the "real" original...

The "main" discussion about this is in the "other" thread, given above in my message... The patch I gave you should work for a fresh version of /etc/bash_completion.d/apt, if you've modified the file the patch may fail. I'll also post the patch in the main thread.

#35

I've attached a patch that should fix the problem, just download it and run this:

sudo patch /etc/bash_completion.d/apt **/path/to/**apt_completion.txt

*(it's a [FONT="Courier New"].txt[/FONT] to bypass the file filter)*

NOTE: The patch may fail if you have previously edited the file, get a fresh one by running:

sudo apt-get install --reinstall apt bash-completion
#36

Since the two bash completion threads were about the same thing, I merged them.

#37

cariboo907 said: Since the two bash completion threads were about the same thing, I merged them.Thank You. (I was the one that asked for that...)

#38

zika said: Thank You. (I was the one that asked for that...)

My apologies, I guess I stupidly caused the 2nd thread. I didn't know that "bash-completion" was the same error I was having. :(

#39

zika said: Thank You. (I was the one that asked for that...)

I merged the thread before I saw your report. :)

#40

@Zika: I don't know why that is there, either: I simply modified the line which caused the error and left everything else intact.

@Penguin Guy: from what I saw in the code-block you posted, you've actually taken out a second entry (and a missing closing parenthesis), too: the bash completion thing seems to check for packages named "$cur" as well as "lib$cur" in the original file. This would suggest that there's some kind of auto-completion of package names going on where you might have autocompletion of qt4-webkit into libqt4-webkit. I'm not sure, though as I don't actually use the apt completion features of this package...

#41

Reiger said: @Penguin Guy: from what I saw in the code-block you posted, you've actually taken out a second entry (and a missing closing parenthesis), too: the bash completion thing seems to check for packages named "$cur" as well as "lib$cur" in the original file. This would suggest that there's some kind of auto-completion of package names going on where you might have autocompletion of qt4-webkit into libqt4-webkit. I'm not sure, though as I don't actually use the apt completion features of this package...

I don't know what happened there, but I somehow deleted the bracket (check the .diff - you'll see they're both there). As for the [FONT="Courier New"]lib$cur[/FONT] part - you're right about what it does. The [FONT="Courier New"]lib$cur[/FONT] part was added by this patch which also caused the error. Being a minor feature, I figured the safest thing was to simply undo the patch until the developers can release a proper fix.

#42

Penguin Guy said: I don't know what happened there, but I somehow deleted the bracket (check the .diff - you'll see they're both there). As for the [FONT="Courier New"]lib$cur[/FONT] part - you're right about what it does. The [FONT="Courier New"]lib$cur[/FONT] part was added by this patch which also caused the error. Being a minor feature, I figured the safest thing was to simply undo the patch until the developers can release a proper fix.I've done the same... Look in the proposed file I've posted. I've done it because I concur with the argument given in aforementioned bug... I do nit want to have lib inserted in front of a string I give for TAB-completion... So, aside from simple syntax correction we (both of us) simply reverted to the previous state of bash_completion algorithm... Of course, by simple omitting ";" on proper places, You could preserve new, proposed behaviour... I beg to differ...

So, to conclude, the final product(s) we gave are the same, only the reasoning behind it is a bit different...

Update: As it can be seen:``` *) COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \ 2> /dev/null ) ) return 0 ;; esac

#43

NOS version of bash_completion is out. This was a nice étude...

#44

new bash is upgraded now

#45

Since this issue is resolved it might be a good idea to mark this thread as solved, thanks.

P.S. Accidental rhyme :).

#46

Penguin Guy said: Since this issue is resolved it might be a good idea to mark this thread as solved, thanks.

P.S. Accidental rhyme :).Rhyme or no rhyme, it was marked [solved] as soon it was solved... At least I do see it as marked...

#47

zika said: Rhyme or no rhyme, it was marked [solved] as soon it was solved... At least I do see it as marked...

Must have got it mixed up with another thread somehow, sorry.

#48

I marked it solved after a saw Penguin Guy's post. :)

#49

cariboo907 said: I marked it solved after a saw Penguin Guy's post. :)

:-k:-\"=D>

#50

cariboo907 said: I marked it solved after a saw Penguin Guy's post. :)

I'm not crazy! :D

#51

Penguin Guy said: I'm not crazy! :DMe too! :)