Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Possible bug: HASH_CMDS has no observable effect



On 2020-09-11 at 10:21 +0200, Roman Perepelitsa wrote:
> From the documentation for HASH_CMDS option:
> 
>   Note the location of each command the first time it is executed.
>   Subsequent invocations of the same command will use the saved
>   location, avoiding a path search. If this option is unset, no path
>   hashing is done at all. However, when CORRECT is set, commands
>   whose names do not appear in the functions or aliases hash tables
>   are hashed in order to avoid reporting them as spelling errors.

So, if and only if CORRECT is set, then non-present commands will be
remembered as not present.

>  % sudo docker run -e TERM -it --rm zshusers/zsh:5.8
>   # print $options[hash_cmds]
>   on

% docker run -e TERM -it --rm zshusers/zsh:5.8
7190647e021a# print $options[hash_cmds] $options[correct]
on off
7190647e021a# setopt correct
7190647e021a# print $options[hash_cmds] $options[correct]
on on
7190647e021a# rsync
zsh: correct 'rsync' to 'sync' [nyae]? n
zsh: command not found: rsync
7190647e021a# apt-get update && apt-get install -y rsync
[...]
7190647e021a# rsync
zsh: correct 'rsync' to 'sync' [nyae]? 

At that point, if you type 'n', then zsh will go ahead and try to run
rsync, and it will succeed.

You will need to run `rehash` (or whatever) before zsh will remember,
for correction purposes, that the command does exist after all.

-Phil




Messages sorted by: Reverse Date, Date, Thread, Author