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' -DPACKAGE='bash
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
> printf "%q\n" works fine here.
It does here too :), I misunderstood the syntax.
> Also, grep "${cur}" could probably be replaced by -path "*/${cur}*".
Indeed it can.
Smaller = better, thanks!
/Mathias
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=
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
wrote:
> On Thu, 24 Sep 2009, David Martin wrote:
>
>> Configuration Information [Automatically generated, do not change]:
>> Machine: x86_64
>> OS: linux-gnu
>> Compiler: gcc
>>
Mathias Dahl 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 I nee
> 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 wo
> 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') o
> 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/\\([][\\(\\) ,\'
On Thu, Sep 24, 2009 at 03:05:07PM -0700, Mathias Dahl wrote:
> I did not find any generic way to quote/escape file names so I
> hardcoded some chars I know exist in my file names and used sed:
printf %q "$filename"
will either insert backslashes in front of all the shell metacharacters,
or $'...
> 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" (
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 $#
> }
> Co
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 $#
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" -
14 matches
Mail list logo