On Fri, Apr 13, 2012 at 3:47 PM, Maxim Gonchar <gma...@gmail.com> wrote:
> I can definitely see the benefit of using it that way, however I think its >> incorrect, and just exploiting a flaw in the complete command. >> > If you run 'complete --help' and check examples you will see the usage of > command arguments with su. I think that it was done intentionally and is > not a flaw. > But that is not for sure. > > Good example, so perhaps it was intentional then. > > There should be a distinction between option arguments and command >> arguments, and given the explanation in the help: >> >> OPTION_ARGUMENTS is parameter containing a space-separated list of >> possible option-arguments, which may contain subshells >> >> I would say '-a' is only to be used for option arguments. >> A new flag could be created for the use cases you describe above. >> (Of course it could be done the other way around as well, that does not >> really matter, as long as the help is updated and reflects the behavior) >> > This looks sane. And everything that should be done for it is to stop fish > calling '-a' script when calling completion of 'cmd -'. Just like Sanskrit > Fritz have written in first message. > > Is that really enough? I would say '-a' should only be evaluated if: 1: If defined with '-s' or '-l', only when completing that specific option. 2: If not defined with '-s' or '-l' in all cases when not completing a option '-' or an argument to an option (where such argument is required). On Sat, Apr 14, 2012 at 10:47 PM, SanskritFritz <sanskritfr...@gmail.com>wrote: > > On Fri, Apr 13, 2012 at 10:46 AM, Maxim Gonchar <gma...@gmail.com> wrote: > >> So it is intentional then. How can I prevent this behaviour? I toyed with >>> __fish_contains_opt, but that is not optimal. I will try to parse >>> commandline --current-token but it gets too complicated, it defies the >>> simplicity of completions. >>> I noticed that in nearly *all* occasions the --arguments script is >>> executed, which is quite annoying if it takes long time just to complete >>> just a simple option. >>> >> >> You can try this: >> complete -c foo -n "not expr match (commandline -t) '^-.*' > >> /dev/null" -a '(sleep 2; echo aaa)' >> >> the '-n' condition is cached. So as soon as you will use the same >> condition for all completions it is not going to be slow. >> > > This is a good solution, thanks! > > Even if this works fine in this case a general solution would benefit all, and would make it easier to write complete functions for everyone. On Fri, Apr 13, 2012 at 5:25 PM, SanskritFritz <sanskritfr...@gmail.com>wrote: > > Hmm, thinking further about this, I came to the following conclusion: when > -a is used alone without -s or -l options in a complete definition, fish > considers it an argument for all options and executes it so it can prompt > all possible option=argument values. Makes sense actually. Question is, how > can we prevent fish to execute the -a if it is intended as an argument for > a command and not for an option. > > This sounds ok to me, but it is still used in two different contexts with somewhat different use cases, but as long as the help is updated and reflects the behavior it should be ok. /Gustaf
------------------------------------------------------------------------------ For Developers, A Lot Can Happen In A Second. Boundary is the first to Know...and Tell You. Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users