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

Re: Literal `~` directory created?



On 2023-05-18 at 14:48 -0400, Tom Vaughan wrote:
> > On May 18, 2023, at 13:59, Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx> wrote:
> > You should have things like:
> > 
> >    zstyle ':completion:*' urls ~/.urls
> >    zstyle ':completion:*' cache-path ~/.cache/zsh/${HOST%%.*}
> 
> Sorry, I'm a bit confused. The previous link is to the zsh source code mirror on GitHub, specifically the definition for _store_cache which is what calls zstyle and mkdir. 

zstyle is used in two ways:

 1. To set a style
 2. To query a style

The _store_cache function queries the style:

    zstyle -s ":completion:${curcontext}:" cache-path _cache_dir
    : ${_cache_dir:=${ZDOTDIR:-$HOME}/.zcompcache}

This is a lookup, for a string (-s); see zshmodules(1) for the
documentation.  Then it supplies a default to use if that resulted in an
empty string (`:`/`true` command, invoked for side-effect of argv
evaluations, and ${param:=default} assignment to populate the variable).

So this does not put a '~' into the cache-path.  Something else has put
that tilde in there.

The _setting_ of the zstyle is done either with nothing between the
`zstyle` and the pattern, or a `-e` for deferred evaluation.  Or a '-'
or '--', pedantically.  The doc entry is:

    zstyle [ - | -- | -e ] pattern style string ...

Somewhere, something in startup files or otherwise is populating some
style settings with a literal tilde in there.

Run:

    zstyle -L | grep '~'

for a first approximation (might include other tildes) of which entries
might have issues.

Try this, to find likely candidates:

    grep "zstyle.*'~" ${ZDOTDIR:-$HOME}/.z*

Now, should zsh have more guards against common misuse like this?
Perhaps, but it's likely to be a quixotic quest.




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