bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange compgen behaviour


From: Mathias Dahl
Subject: Re: Strange compgen behaviour
Date: Thu, 24 Sep 2009 15:05:07 -0700 (PDT)
User-agent: G2/1.0

> ...but then I have to shell quote the file name myself to handle
> spaces, brackets of various sorts, comma characters etc. Will hunt for
> such a function and see. There are all sorts of crazy helper functions
> in /etc/bash_completion, of which I barely understand anything.

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:

_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/\([\(\) ,]\)/\\\1/g')
    local IFS=$'\n'
    COMPREPLY=(${files})
}
complete -F _mm mm

However, I don't like it, is feels ugly and one of these days there
will be some other funky char in some filename... :(

/Mathias


reply via email to

[Prev in Thread] Current Thread [Next in Thread]