help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Performing quote removal on data


From: Maarten Billemont
Subject: Re: [Help-bash] Performing quote removal on data
Date: Wed, 28 May 2014 16:49:49 -0400

On May 28, 2014, at 4:44 PM, Greg Wooledge <address@hidden> wrote:

> On Wed, May 28, 2014 at 04:05:47PM -0400, Maarten Billemont wrote:
>> 2a. One such case is doing pathname completion, but here we can fall back to 
>> compgen -o bashdefault:
>> 
>> IFS=$'\n' read -r -d '' COMPREPLY < <(compgen -o bashdefault "$partial*") # 
>> notice the trailing *
> 
> I think you've taught me that I don't know a damned thing about bash
> programmable completion.
> 
> imadev:~/tmp$ mkdir -p "dir "{1,2}
> imadev:~/tmp$ echo dir*
> dir 1 dir 2
> imadev:~/tmp$ compgen -o bashdefault "di"
> imadev:~/tmp$ compgen -o bashdefault "di*"
> imadev:~/tmp$ compgen -o default "di"
> dir 1
> dir 2
> imadev:~/tmp$ compgen -o default "di*"
> imadev:~/tmp$ rmdir dir\ [12]
> 
> Sorry if I misunderstood the goal.  Apparently, I don't understand the
> compgen command either.
> 
> Good luck.

Interesting.  You're probably running an older bash version then, because for 
me:

$ mkdir -p "dir "{1,2}
$ echo dir*
dir 1 dir 2
$ compgen -o bashdefault "di"
$ compgen -o bashdefault "di*"
dir 1
dir 2
$ compgen -o default "di"
dir 1
dir 2
$ compgen -o default "di*"

So it appears we can only really rely on -o default "$partial", but then 
pathname expansion is definitely out.

I do expect that your bash completes echo dir*[tab] and gives you dir 1 and dir 
2 as completion options?

— Maarten Billemont (lhunath) —
me: http://www.lhunath.com – business: http://www.lyndir.comhttp://masterpasswordapp.com

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail


reply via email to

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