bug-bash
[Top][All Lists]
Advanced

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

Re: Idea: *.p<TAB> completion


From: Eli Schwartz
Subject: Re: Idea: *.p<TAB> completion
Date: Sun, 1 Sep 2019 15:15:21 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

On 9/1/19 2:35 PM, 積丹尼 Dan Jacobson wrote:
> Yes. That's why I'm saying wouldn't it be neat if it made
> *.p into *.pdf? What harm could possibly happen?
> The idea being if the user has handed it an asterisk,
> then he wants that asterisk to still be in the result.

Why should shell completion be responsible for auto-filling your globbed
search pattern?

Let's say it did, in fact, auto-fill your globbed search pattern. What
if I had a bunch of files in my current directory:

a.pdf
b.pdf
hello_world.py
*.pl

What should *.p complete to? It could be *.pdf or *.py or *.pl, and
since the shell doesn't know which one I want, it won't complete either
-- instead, it will print them to the screen and let me choose. But then
that's going to confuse me, because the completions will list two globs
(*.pdf and *.py) and one actual literal filename *.pl (because my
example persona is a weird person with weird taste in filenames).

Which one do I want?

And my expectation as a user is that tab-completing a filename should
only offer me real filename suggestions (which AFAIK seems to currently
be the case), and I would get quite freaked out if bash started
completing glob patterns too. I would be freaked out enough to report a
bug and demand an option to disable this behavior (and offer my opinion
that disabling it should be the default).

...

What is even the purpose of this anyway? If you only have .pdf files,
your glob can be *.p* and it works as-is, it is even the same number of
keys. If you have multiple possible suffixes, bash won't even complete
it for you, but only fill out the unambiguous characters and then make
you finish the rest -- so use * instead of tab, and then fill out the
rest anyway. You are already using a glob, I would expect that your glob
has a highly specific use case which you know more about than bash does.
I'm sure there is some trivial glob suffix you can use which is as few
keypresses or less than anything bash could do for you, and is as a
bonus generally portable between shells and even different point
releases of bash.

-- 
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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