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

Re: help for writing GNU stow completion



On 17 Aug 2019, at 12:53, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> 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.

Oh, i didn't notice that the GitHub thing was a PR for zsh.

I agree with this. And i can't think of a general-purpose alternative that's
currently built into the shell.

Apparently i made the same mistake when i wrote _composer, though; attached
replaces the eval by (as i mentioned) what seems to be the prevailing
convention. I think a similar change might be warranted in _git @ 2866?

dana


diff --git a/Completion/Unix/Command/_composer b/Completion/Unix/Command/_composer
index 2b9f2cd32..191350453 100644
--- a/Completion/Unix/Command/_composer
+++ b/Completion/Unix/Command/_composer
@@ -115,7 +115,7 @@ __composer_prune_global_opts() {
 (( $+functions[__composer_update_work_dir] )) ||
 __composer_update_work_dir() {
   if [[ -n ${(v)opt_args[(i)(-d|--working-dir)]} ]]; then
-    eval _composer_work_dir=${(v)opt_args[(i)(-d|--working-dir)]}
+    _composer_work_dir=${(Q)${(v)opt_args[(i)(-d|--working-dir)]}}
   elif [[ -z $_composer_work_dir ]]; then
     _composer_work_dir=$PWD
   fi



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