[Bash-completion-devel] Bug#575527: bash-completion: completion for Scilab

Gib gibboris at gmail.com
Sun Mar 28 21:54:03 UTC 2010


On Fri, Mar 26, 2010 at 04:15:01PM +0100, Sylvestre Ledru wrote:
> # Scilab completion
> # Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
> # Copyright (C) DIGITEO - 2010 - Sylvestre Ledru
> # This file must be used under the terms of the CeCILL.
> # This source file is licensed as described in the file COPYING, which
I don't know a lot about that excepted that COPYING doesn't contains
anything about CeCILL (which AFAIR is GPL-compatible isn't ?)
> # you should have received as part of this distribution.  The terms
> # are also available at    
> # http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
missing "have ... && {" function call and condition
 > 
> _scilab()
> {
>     local cur prev options
>     COMPREPLY=()
>     cur=${COMP_WORDS[COMP_CWORD]}
>     prev=${COMP_WORDS[COMP_CWORD-1]}
use _get_cword and _get_pword

> 
>     # List all options. Note that 
>     options='-ns -nb -nw -nwni -nogui -debug -debug-kdbg -d -display
>     -profiling -profiling-visu -l -mem -version -e -f -nouserstartup
>     -args -mem -h --help'
only list short options which have not a long equivalient (I didn't
verified as I didn't find the man page on the web)
> 
>     # Loop on the arguments to manage conflicting options
>     for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
you can start from 1
> 	#exclude some mutually exclusive options
> 	[[ ${COMP_WORDS[i]} == '-nwni' ]] && options=${options/-nw}
[[ ${COMP_WORDS[i]} = -nwni ]] is also correct
>         [[ ${COMP_WORDS[i]} == '-nw' ]] && options=${options/-nwni}
>         [[ ${COMP_WORDS[i]} == '-e' ]] && options=${options/-f}
>     done
I went over this issue some times ago
(http://www.mail-archive.com/bash-completion-devel@lists.alioth.debian.org/msg01042.html
and successives posts)
There isn't yet any helper in the BC core to do this job (exclusive options).
IMHO your solution is pretty enough.
>     
>     case "$1" in
I would have used ${COMP_WORDS[0]} = scilab-cli but it may also be
robust afterall. A simple condition like :
[[ ${COMP_WORDS[0]} = scilab-cli ]] && options=${options/-nw}
seems enough.
>     	 *scilab-cli*)
> 		# Option -nw is not available
>             	options=${options/-nw}
> 	;;
>     esac
> 
>     case $prev in
>         -f)
> 		_filedir '@(sci|sce|SCI|SCE|tst|TST)'
> 		return 0
>             ;;
>         -e|-l|-d|-display|-mem)
> 		cur=${cur#[\"\']}
don't know (nor checked out) why, but if you're sure about that
> 		eqext='='
this one I don't get it
>             ;;
> 	
>         *)
>             COMPREPLY=( $( compgen -W "$options" | grep "^$cur" ) )
should be COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
>             ;;
>     esac
> 
>     return 0
> }
&&
> complete -F _scilab $filenames scilab scilab-cli scilab-adv-cli
I'm not quite sure about the devs opinion regarding $filenames

wish theses tips 'll help
Raph





More information about the Bash-completion-devel mailing list