[Bash-completion-devel] mount -o options completions & COMP_WORDS: error

gibboris at gmail.com gibboris at gmail.com
Fri Nov 20 18:41:22 UTC 2009


Hi,
I sometimes have to use the mount options
manually (eg, -o ro,users, ...)
I would like to know if there are any plans to
move it outside _the venerable_ bash_completion script.

To do this option completion (if it's interesting enough) it needs :

I) get the fstype, so grab the -t option in the commandline
   1) does a __get_opt_value [--long=[separator]|--short] option_name
   would be nice ?

   2) fstype="$(__get_opt_value --short -t)"

II) get options of this fstype
   1) with an associative array like :
   declare -A allfstypes;
   allfstypes[adfs]=uid,ownmask;
   allfstypes[ext3]=....;
   ...
   allfstypes[common]=async,atime,...;

III)
   elif [[ "$prev" == -o ]] && [[ ${BASH_VERSINFO[0]} -ge 4 ]]; then
   	cur optval=_get_cword ,
   	local compstr=${fstypes[$allfstypes]},${fstypes[common]}
   	COMPREPLY=( $(compgen -W "${compstr//,/ }" -- "$optval" )

I also noticed something (I'm probably not the first but I did't see bug reports about that) :
$ ls
[ then go at the beginning of the line ]
[ then press <tab> ]
bash: COMP_WORDS: bad array index

With $ mount, it adds :
bash: [: = : unary operator expected [twice]

Raph



More information about the Bash-completion-devel mailing list