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

Re: help for writing GNU stow completion



(idk what's up with the ???? here, it says UTF-8 but it's all messed up)

On 20 Aug 2019, at 12:45, Aurélien <orel_jf@xxxxxxxx> wrote:
> But now if I do ?? stow --dir=$HOME/.dotfiles<TAB> ??, I get ????no packages
> found in $HOME/.dotfiles????. Maybe I missed something???

It's because of what i said before — the argument you're passing to that
helper function is the raw, unevaluated text from the command line, so it
isn't expanding $HOME. The only easy way i can think of to *make* a completion
function expand that is to evaluate it, which you can do with eval or, as i
forgot to mention before, the (e) expansion flag. But if you do that, there is
a chance (though probably not a huge one) that you might trigger unexpected
and potentially even destructive side-effects when the user invokes
completion, which is why Daniel objected to it.

If there were some kind of 'safe eval' that just performed 'read-only'
parameter expansions, you could use that, but as far as i know there isn't
currently anything like that that's built into the shell, and it's not ideal
to special-case this one function.

So, without a general solution, the more limited version in your last message
might be the best option for now

dana



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