Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: help for writing GNU stow completion
- X-seq: zsh-users 24154
- From: Aurélien <orel_jf@xxxxxxxx>
- To: dana <dana@xxxxxxx>
- Subject: Re: help for writing GNU stow completion
- Date: Sat, 17 Aug 2019 09:48:45 +0200
- Autocrypt: addr=orel_jf@xxxxxxxx; prefer-encrypt=mutual; keydata= mQINBFnrjSUBEADGm1wZcrhssIdITo581Nen6VlNeO/Yh28fmlYhKtSME53emVhg7TYqu/cM eJV1SxRE/fZCx7yNX9IARCjCuhvXRrsLoxbuRHlybALDfByv7OJBUJhd6JU/Trubx68fLs+W fKXqRqNN4Pobezgg8/vA9LU/aWhj46LCOcFD0MpxfnxW56IzunV443xlYUGdDehdBEosUNlf 9KuJ24d5PpgzNHe9bB6LVLZvVoO164aAoeKLifC8MtV11JOk43wsZkM1ZCNjt3GU2qFv4/Jo 6M9Wo6oLvuvnh1xKrCJa/zh3Kx3IQ1CbNjXHLna5TF7Zx6KLUUNaLnFzymdMjnzvnLyH1GvA N7yKcyG5uKaqZGq2v8h20fcp/ag/SoZOhC9TMELBGlSuwoTV0qXX/uYaraxAaCwBIENL8tKp Kqo5LX4AgTKHq60C6rJnjTUSX68RbvSEJacoIzVXMM1wpGOmp0fH4KqHsaN9pTOQ4vuU+K7f ptTqmWiBZXTqRCmIo11AC3Po50EeeYdtjB+OMfvNLSk5q226/gR9p5oBc58B0zeG9Kt1nl33 zG01spC20rv7awXhw5WMeGR14mZ5X5UShb5hIyA3bSyErGuvN+J0HCCN3WdH3ZEO2Ols20az QCZwZwcwju/06ZDGAJzoTxqMeOIFHWwPDrcbXpbinR8EacwTkQARAQABtCRBdXLDqWxpZW4g T0xJVklFUiA8b3JlbF9qZkB5YWhvby5mcj6JAlQEEwEIAD4WIQRpjQYRG7yMFUmG5I9INEIz GKktMAUCWeuNJQIbAwUJA8JnAAULCQgHAgYVCAkKCwIEFgIDAQIeAQIXgAAKCRBINEIzGKkt MDt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RqF3LoJJe+u3Q1lcPfkjtn6
- Cc: zsh-users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.fr; s=s2048; t=1566028128; bh=IaJS9jrhlw6u8pGHAIFBZPAjug29d6d60M7UyBltYyg=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=ONGeEHv7mk47AgnBzixHkyancMnyqGRXIX5UYb1pa6nYTOzwtWjPLaPxz3q2/c5kZeVHmg6Eg/GBhNR1SzG2zYSFDj24HqIFGxtEyTB0jdjxS6fiYO6D7Re93HLq6T3hGn/lH/hTXqVXdqZcZ6+kERvFZb5xd0VpVoJDnHogZuKRZbXc4HX7ZtTET9VC6zEMCRDiPKn0DQhniaN8GlnCb3SErDJY+ZQMca0DZqPJVvxG/C8QnO7Ls+3p2eg9zgX8jVw4dDHRfjnVyupDf2VYs0hSn3cKBSG2GlLPB7BWaweRliIHQMkxihlMIppzpOZO0T22laHdFqRGQVT+zvx44A==
- In-reply-to: <BAE67462-BF39-481A-BCD6-DE288FE6CC92@dana.is>
- 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
- Openpgp: preference=signencrypt
- References: <1e5195bb-3126-8d0c-8a6a-1f5a5fd2a6c0@yahoo.fr> <BAE67462-BF39-481A-BCD6-DE288FE6CC92@dana.is>
Le 16/08/2019 ?? 01:36, dana a ??crit??:
> 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)
>
Knowing that this option only accepts one value and after a few tests,
it seems that 'eval' is the right solution, . My function now looks like
this:
local stow_dir
local -a stow_pkg_list
eval set -A stow_dir $1
[[ -n $stow_dir ]] && stow_pkg_list=( $stow_dir/*(-/N:t) )
if [[ ${#stow_pkg_list} -gt 0 ]]; then
_values -C "packages from $stow_dir" ${stow_pkg_list[@]}
else
_message "no packages found in $stow_dir"
fi
and the completion of parameters such as'$HOME' or'~/' works well !
I pushed my modifications on github. Thank you for the answers :-)
--
Aur??lien
Messages sorted by:
Reverse Date,
Date,
Thread,
Author