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

Re: Proof of concept mainstream plugin manager



On Jan 27,  8:34am, Sebastian Gniazdowski wrote:
} Subject: Re: Proof of concept mainstream plugin manager
}
} > Sebastian has already changed that whole thing to be
} >
} > functions[$func]="_reload_and_run ${(q)PLUGIN_DIR} $opts $func "'"$@"
} 
} I commited your eval way to recognize it in battle (Polish idiom,
} wonder if it works in English). Without quoting in ${(qq)opts}, what
} you recommended earlier, I get list of all defined functions

Oh.  Yes, you need to pass empty string there if there are no options,
because _reload_and_run interprets its first 3 arguments positionally
and all are required to be present.  Sorry about that.

So if you want to use the assignment form, you need

functions[$func]="_reload_and_run ${(q)PLUGIN_DIR} ${${(q)opts[@]}} $func "'"$@"'

The ${(qq)opts[@]} quotes every element separately, and then the outer
${...} compbines the result into a single string again.

} > which yes, is going to do strange things if $func contains spaces.
} >
} > On the other hand, the whole plugin would already be broken if $func
} > contains spaces.  I'd rather not "fix" it in an unpredictable way.
} 
} What do you mean? Shouldn't I do quoting, i.e. ${(q)func} ?

Whether you want the (q) is entirely up to you.  The result will be
broken if there are any spaces in $func whether you (q) or not,
because functions[$func]=... will already have created something
that can't be run.

Back on the first hand, I suppose if $func somehow contains a semicolon
or some globbing characters, rather than just spaces, then you should
quote those.  So yes, ${(q)func} is better.



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