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
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
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
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
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/\\([][\\(\\)
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
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:
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
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
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
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
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'
12 matches
Mail list logo