[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `set completion-ignore-case on' does not work well for the first wor
Re: `set completion-ignore-case on' does not work well for the first word on command line
Mon, 18 Feb 2008 09:15:13 +0800
On Feb 18, 2008 3:59 AM, Chet Ramey <address@hidden> wrote:
> Jian Wang wrote:
> > On Feb 17, 2008 5:21 AM, Chet Ramey <address@hidden
> > <mailto:address@hidden>> wrote:
> > Jian Wang wrote:
> > > When using Bash, I often turn on the `completion-ignore-case'
> > option of
> > > readline. It works fine for most cases but sometimes it does not
> > work as
> > > expected when completing the first word on the command line. For
> > example,
> > > there is a bash script ~/MyDir/Foo.sh, on command line, when I
> > input ~/my
> > > and then press TAB, the word is completed as ~/myDir . Is that a
> > It's not really a bug, since case-ignoring does not necessarily mean
> > case-changing (this is usually called `case-preserving'). Readline
> > what's found in the file system rather than preserving what the user
> > typed, though, as you noticed when you tried to do word completion
> > instead
> > of command completion. It might be useful to emulate Readline's
> > behavior
> > while doing command word completion.
> > Thanks for your reply but I'm a bit confused. You said that readline
> > uses what's found in the file system rather than preserving what the
> > user typed. But for my example, ~/MyDir should be found in the file
> > system but why it's completed as ~/myDir? Readline behaves differently
> > between word completion and command completion? Or, command completion
> > is done by Bash itself other than readline?
> Readline does a fine job of completing filenames in the current
> directory, or completing a full pathname. Since command completion
> is inherently application-specific and doesn't match well with that
> limited set of capabilities, bash does it internally, only resorting
> to readline in a couple of cases. The way bash does things results
> in this one specific instance differing from readline's filename
Thank you so much.
> > And I noticed that if I
> > first input /home/myname/my and than press TAB, it'll be correctly
> > completed as /home/myname/MyDir . What's the difference?
> The tilde prefix, which needs to be expanded so pathnames can be checked
> for the correct attributes (e.g., executability) and then removed. If
> you look at the code, you'll see that bash appends the remainder of a
> completed pathname to what the user typed, which includes the tilde
> prefix, since the rest of the code has to expand the tilde prefix before
> doing the checking it needs to.
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
> Live Strong. No day but today.
> Chet Ramey, ITS, CWRU address@hidden
> http://cnswww.cns.cwru.edu/~chet/ <http://cnswww.cns.cwru.edu/%7Echet/>