bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bash command completion sometime behave erroneously specifically return


From: Hyunho Cho
Subject: bash command completion sometime behave erroneously specifically return 0
Date: Tue, 29 Jan 2019 09:16:12 +0900

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  -Wdate-time 
-D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/bash-aZTmfT/bash-4.4.18=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wall 
-Wno-parentheses -Wno-format-security
uname output: Linux EliteBook 4.18.0-13-generic #14-Ubuntu SMP Wed Dec 5 
09:04:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.4
Patch Level: 19
Release Status: release

Description: 
 
################################################################## 
 
bash command completion sometime behave erroneously
almost works correctly but some cases do not work
specifically return 0 when press tab key

this is the script i have used and i will attach screenshot recording

###################################################################
_kill2()
{
    local CUR=${COMP_WORDS[COMP_CWORD]} WORDS
    local IFS=$' \t\n'

    case $CUR in
        -*)
            WORDS=$( kill -l | sed -rz 's/[0-9]+\) SIG/-/g' )
            COMPREPLY=( $(compgen -W "$WORDS" -- "$CUR") )
            ;;

        *)
            WORDS=$( ps haxo pid,user,comm | awk 'BEGIN {IGNORECASE=1}
            $3~/'"$CUR"'/{a[i++]=$0} END{
            if (isarray(a)) {
                if (length(a) == 1) print a[0]
                else {
                    len=length(i)
                    for (i in a)
                        printf "%0*d) %s\n", len, i, a[i]
                }
            }}')
           
            IFS=$'\n'
            COMPREPLY=( $WORDS )
            ;;
    esac
}

complete -F _kill2 kill
###################################################################

Attachment: bug_report.mp4
Description: video/mp4


reply via email to

[Prev in Thread] Current Thread [Next in Thread]