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

Re: Literal `~` directory created?




> On May 18, 2023, at 12:52, Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx> wrote:
> 
> On 2023-05-18 at 13:59 +0000, thomas.david.vaughan@xxxxxxxxx wrote:
>> I ran `brew bundle install` in a newly created directory which contained only
>> a Brewfile, and noticed that afterwards a directory named `~` had been
>> created:
> 
>> I have noticed this before perhaps as far back as three months ago, but I
>> never could narrow it down enough to understand what might be causing this. I
>> would see this after I ran some homemade scripts I wrote to maintain the
>> software installed on my laptop. These scripts always ran brew so maybe it's
>> the culprit?
> 
> The expansion of `~` is something which the shell does when invoking a
> command, but if the command is getting a value from a configuration file
> then it needs to be supported on a per-app basis, because then the shell
> isn't involved doing some of the work for it.
> 
> Similarly, if you have something which wants to use `~` as the default
> value for a flag, then that's going to be ... "iffy".
> 
> So grep for '~' in your config files and try replacing it with $HOME
> instead, see if the command does env-var expansion or if you end up with
> a directory named '$HOME' in your home-dir.  :^)
> 
> There's nothing zsh-specific or zsh-involved here: the problem is
> arising _because the shell is not being involved_.

Thanks, Phil. Based on this it seems like the problem is due to:

    mkdir -m 0700 -p "$_cache_dir"

at https://github.com/zsh-users/zsh/blob/master/Completion/Base/Utility/_store_cache#L19

Tilde is not expanded when quoted, right? _cache_dir is set a little higher up at https://github.com/zsh-users/zsh/blob/master/Completion/Base/Utility/_store_cache#L10:

    $ echo $_cache_dir

    $ zstyle -s ":completion:${curcontext}:" cache-path _cache_dir

    $ echo $_cache_dir
    ~/.cache/zsh/compcache

Perhaps this tilde should be expanded? Running the mkdir command above creates a literal '~' directory in the current working directory.

-Tom





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