Re: Strange compgen behaviour

2009-09-25 Thread Bernd Eggink
Mathias Dahl schrieb: Hm, compgen appears to behave strange if words contain whitespace. However, you don't need it, as you build the list yourself. Try this: _mm2() { local cur files cur=${COMP_WORDS[COMP_CWORD]} files=$(find /home/mathias/Videos/movies/ -iname $cur*.avi

Re: Real easy questions. Please answer

2009-09-25 Thread Dave B
On Friday 25 September 2009 05:24:04 eatsubway wrote: sry i have a stupid question. I have a variable and need to know how many items are in it. for example: variable=abc xyz foo what program can i call to print out 3 right now im doing this... Counter() { echo $# } Counter

Re: Real easy questions. Please answer

2009-09-25 Thread Chris F.A. Johnson
On Thu, 24 Sep 2009, eatsubway wrote: sry i have a stupid question. I have a variable and need to know how many items are in it. for example: variable=abc xyz foo what program can i call to print out 3 right now im doing this... Counter() { echo $# } Counter $IDs but

Re: Strange compgen behaviour

2009-09-25 Thread Mathias Dahl
Hm, I can't see any problem here. My version lets you pick any file in any subdir by simply typing the name (or part of it) without the directory part. After all, 'find -name' matches names, not paths (if you want to match full paths, use 'find -path'). I'd also rather use printf %P\n

Re: Strange compgen behaviour

2009-09-25 Thread Mathias Dahl
This has been an interesting topic! I thought I should share the final version as well: _mm() { local cur files COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} files=$(find /home/mathias/Videos/movies/ -iname *.avi -type f - printf %P\n | grep ${cur} | sed s/\\([][\\(\\)

Re: Strange compgen behaviour

2009-09-25 Thread Mathias Dahl
printf %q $filename will either insert backslashes in front of all the shell metacharacters, or $'...' quote the whole thing, or take some other action which renders a string safe.  It's basically the opposite of eval. Interesting! Can I make it part of my pipe (in place of `sed') or need I

Re: Strange compgen behaviour

2009-09-25 Thread Mathias Dahl
Interesting! Can I make it part of my pipe (in place of `sed') or need I change it to a for or while loop? This is what I have now: files=$(find /home/mathias/Videos/movies/ -iname *.avi -type f - printf %P\n | grep ${cur} | sed s/\\([][\\(\\) ,\']\\)/\\1/ g) Got this to work:

Re: Strange compgen behaviour

2009-09-25 Thread Andreas Schwab
Mathias Dahl mathias.d...@gmail.com writes: Got this to work: files=$(find /home/mathias/Videos/movies/ -iname *.avi -type f - printf %P\n | grep ${cur} | while read file; do printf %q $file echo done) With the %q option to printf it no longer accepts a \n so

Re: Bug in array populating does not respect quotes

2009-09-25 Thread David Martin
Thank you for all and sorry for the noise, you were right. David. On Thu, Sep 24, 2009 at 6:38 PM, Chris F.A. Johnson ch...@cfajohnson.com wrote: On Thu, 24 Sep 2009, David Martin wrote: Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu

Re: Strange compgen behaviour

2009-09-25 Thread Chet Ramey
Bernd Eggink wrote: Chet Ramey schrieb: Hm, compgen appears to behave strange if words contain whitespace. Well, it splits the argument to -W on $IFS as documented. What other strange behavior do you see? For example, this: function _aha { local list=a b:c d:e f

Re: Strange compgen behaviour

2009-09-25 Thread Bernd.Eggink
Chet Ramey schrieb: Bernd Eggink wrote: Chet Ramey schrieb: Hm, compgen appears to behave strange if words contain whitespace. Well, it splits the argument to -W on $IFS as documented. What other strange behavior do you see? For example, this: function _aha { local list=a

Completion called within command substitution

2009-09-25 Thread Freddy Vulto
Configuration Information [Automatically generated, do not change]: Machine: i486 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale'