Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: help for writing GNU stow completion
- X-seq: zsh-users 24145
- From: dana <dana@xxxxxxx>
- To: Aurélien <orel_jf@xxxxxxxx>
- Subject: Re: help for writing GNU stow completion
- Date: Thu, 15 Aug 2019 18:36:57 -0500
- Cc: zsh-users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=C8Bb9rRfYoe4IwDr13DKUHr3R9ofatyogglhg10AMsg=; b=fU0kBK81xNNIZu/D3yutWkf7ZVzQ3/1a2B1Fjvc3iZ8teE0BLrtvaH3JKIWyaNDWoY 0vvoeiL6Mp1YMsEEToU/6eITOz2gDMBMY3f9ttRK/qhLWMgx03WspbHlci67lmJnRpg9 vlTCJH8e+mSYif9gYQrx0NTEeOI8sqMA3ayVS/2+jk5OiwA2ZfllzEh3//LDQxaWsVRI 2NFHJ6j5gy2GXc4IkJwb3+QazUjIOtYKPRJZdKYaYgyiDn9kqGf3oT4tVVXrNPi+6wxx RY8d7EMjQI1/GBhGG9KB1YXaAAswaYb+n2v8FTTZ5nw6FM6bb9VOcitLiBebkdQfss09 7OKw==
- In-reply-to: <1e5195bb-3126-8d0c-8a6a-1f5a5fd2a6c0@yahoo.fr>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <1e5195bb-3126-8d0c-8a6a-1f5a5fd2a6c0@yahoo.fr>
On 6 Aug 2019, at 12:04, Aurélien <orel_jf@xxxxxxxx> wrote:
> From the command line, when I try to complete something like this:
>
> % stow --dir=$HOME/.dotfiles/
>
> I get: 'no packages found in $HOME/.dotfiles/'
>
> It seems that "$HOME" is not evaluated, and it is the same with "~". Is
> there a way to evaluate these elements?
Sorry for the late reply (haven't been paying attention to the ML much
recently), but if you still need help with this:
Completion functions get arguments on the command line in a 'raw' form,
exactly as they're given, including unexpanded parameters, leading tildes,
quotes, &c. That's why you get a literal $HOME instead of its value.
You can use the (Q) expansion flag to strip quotes, which is a semi-common
thing in completion functions when they need to take user input from the
command line, but there's no flag for anything fancier, and most functions
don't seem to bother with it. But if you wanted to, something like this is
probably the best way...?
local -a stow_pkg_list
eval set -A stow_pkg_list $1
[[ -n $stow_pkg_list ]] && stow_pkg_list=( $stow_pkg_list/*(-/N:t) )
It's not perfectly accurate, though; for example, because of how _arguments
breaks up optargs, this would treat `--dir=~/foo` and `--dir ~/foo` the same,
even though the tilde would not actually be expanded before passing it to stow
in the former case (unless magic_equal_subst was enabled)
dana
Messages sorted by:
Reverse Date,
Date,
Thread,
Author