简体   繁体   中英

Bash completion programming , '@' is always removed in completion string

I'm doing a bash completion for Gentoo , which search for packages , sets ( portage 2.2 new feature ) , but i met a problem when i'm using the following command:

emerge @pres

And i'm supposed to get @preserved-libs , but bash turns it into:

emerge pres

First thought would be problem with my script called "emerge-finder.pl" , so i double checked , and this script gave the right output.

And next i checked bash script:

_portage_cmd () {
        COMPREPLY=( `~/scripts/emerge-finder.pl ${COMP_WORDS[COMP_CWORD]}` )

}
complete -F _portage_cmd em

And i put a "echo ${COMP_WORDS[COMP_CWORD]}" before COMPREPLY line , and there's no output of "@" character , wired.

How can i keep my "@" from stripping off by bash ? Many thanks !

Quoting or escaping it might help...

So quoting :

emerge '@pres'

Or escaping :

emerge \@pres

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM