What does shopt -s dirspell do?
Asked Answered
C

2

14

I cannot figure it out, i understand shopt -s cdspell but cannot find out what shopt -s dirspell does.

The Bash Reference Guide says:

dirspell

If set, Bash attempts spelling correction on directory names during word completion if the directory name initially supplied does not exist.

I tried several times on several directories but that is not the behavior.

I'm using bash 4.2.10(2) on i386-apple-darwin10.7.0

Congregationalism answered 22/6, 2011 at 10:25 Comment(0)
D
10

From the change-log

x. There is a new shell option: `dirspell'. When enabled, the filename completion code performs spelling correction on directory names during completion.

Let's try:

$ ls
spam/

$ cat spam/test 
hello world

without dirspell

$ cat span/test [tab]
# nothing happens

with dirspell

$ shopt -s dirspell
$ cat span/test [tab]
#line is replaced by
$ cat /home/user/tmp/shopt/spam/test
Dhow answered 22/6, 2011 at 10:50 Comment(3)
Props for hinting that dirspell works from the second level of files/dirs, what actually makes sense, but when i tabcomplete, the second level file or dir gets completed with a space afterwards, and the result is a No such file or directory, which makes this shopt basicaly unpractical,useless, sensles for me? @FrederikCongregationalism
Yeah, I also do not get the line replacement. Rather, the tab-completion works, but then the typo gets sent to the command so the command itself fails.Foreknow
I don't see anything happening when I hit tab, with dirspell on.Gahan
C
8

If you set the shell options direxpand and dirspell, then the tab-completion does work.

Contemplative answered 1/12, 2015 at 9:7 Comment(2)
direxpand is available since 4.3-alpha.Bellicose
This is the important detail that is actually required for the dirspell option to work. The manpage makes no mention of this, which is why OP and I were both utterly perplexed.Atropine

© 2022 - 2024 — McMap. All rights reserved.