zsh-workers
 help / color / mirror / code / Atom feed
* Zsh CORRECT option is unaware of AUTO_CD and CDABLE_VARS
@ 2019-08-26 13:59 Cameron Steffen
  2019-08-27  2:59 ` Jun T
  0 siblings, 1 reply; 3+ messages in thread
From: Cameron Steffen @ 2019-08-26 13:59 UTC (permalink / raw)
  To: zsh-workers

Hello,

Copied from my question here:
https://unix.stackexchange.com/questions/537111/zsh-correct-option-is-unaware-of-auto-cd-and-cdable-vars

Is there a way to make the CORRECT option aware of AUTO_CD and
CDABLE_VARS? In this example, I would expect correction to not be
triggered. Could this be a bug?

> setopt autocd
> setopt cdablevars
> setopt correct
> vimz=/var
> vimz
zsh: correct 'vimz' to 'vim' [nyae]?

Thanks,
Cameron

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Zsh CORRECT option is unaware of AUTO_CD and CDABLE_VARS
  2019-08-26 13:59 Zsh CORRECT option is unaware of AUTO_CD and CDABLE_VARS Cameron Steffen
@ 2019-08-27  2:59 ` Jun T
  2019-08-27  3:43   ` Jun T
  0 siblings, 1 reply; 3+ messages in thread
From: Jun T @ 2019-08-27  2:59 UTC (permalink / raw)
  To: zsh-workers


> 2019/08/26 22:59、Cameron Steffen <cam.steffen94@gmail.com> wrote:
> 
> Is there a way to make the CORRECT option aware of AUTO_CD and
> CDABLE_VARS? In this example, I would expect correction to not be
> triggered. Could this be a bug?
> 
>> setopt autocd
>> setopt cdablevars
>> setopt correct
>> vimz=/var
>> vimz
> zsh: correct 'vimz' to 'vim' [nyae]?

The patch below seems to fix this problem.
I hope this has no obvious bad side effects.


diff --git a/Src/utils.c b/Src/utils.c
index 46cf7bcf6..02fbdb351 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -3147,6 +3147,8 @@ spckword(char **s, int hist, int cmd, int ask)
 	}
 	if (access(unmeta(guess), F_OK) == 0)
 	    return;
+	if (cd_able_vars(guess))
+	    return;
 	best = spname(guess);
 	if (!*t && cmd) {
 	    if (hashcmd(guess, pathchecked))




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Zsh CORRECT option is unaware of AUTO_CD and CDABLE_VARS
  2019-08-27  2:59 ` Jun T
@ 2019-08-27  3:43   ` Jun T
  0 siblings, 0 replies; 3+ messages in thread
From: Jun T @ 2019-08-27  3:43 UTC (permalink / raw)
  To: zsh-workers



> 2019/08/27 11:59、I wrote:
> 
> I hope this has no obvious bad side effects.

Sorry, is this better?


diff --git a/Src/utils.c b/Src/utils.c
index 46cf7bcf6..2c4726fa0 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -3159,6 +3159,8 @@ spckword(char **s, int hist, int cmd, int ask)
 	    scanhashtable(cmdnamtab, 1, 0, 0, spscan, 0);
 	    if (autocd) {
 		char **pp;
+		if (cd_able_vars(guess))
+		    return;
 		for (pp = cdpath; *pp; pp++) {
 		    char bestcd[PATH_MAX + 1];
 		    int thisdist;




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-27  3:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-26 13:59 Zsh CORRECT option is unaware of AUTO_CD and CDABLE_VARS Cameron Steffen
2019-08-27  2:59 ` Jun T
2019-08-27  3:43   ` Jun T

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).