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

Re: help for writing GNU stow completion



[moving to -workers@ since it's about an outstanding PR]

Aurélien wrote on Sat, 17 Aug 2019 07:51 +00:00:
>   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 :-)

Sorry, but I have to object to the PR as it stands.  As I said, using
«eval $1» causes expressions on the command line to be evaluated
_when completion is attempted_.  To me, that breaks the principle of
least surprise, and could lead to unexpected and undesired results.

I would strongly prefer another solution, or to be corrected on my
interpretation that this violates least surprise.

Also, I don't think it's ideal to have «foo --opt=$ARG<TAB>» work and
«bar --opt=$ARG<TAB>» not work.

Cheers,

Daniel



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