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

Re: view onto command pipeline?



On Wed, Jul 20, 2022, at 7:37 AM, Dominik Vogt wrote:
>   command git "${opts[@]}" "$@"
> As a rule of thumb, _never_ use unquoted variables in shell scripts

That's a very unequivocal rule-of-thumb then :-).  For me, zsh's word-splitting rule is one
of its best features, and I think anyone who turns it off deserves all their pain!  Agree
quoting $@ makes sense here since this is a wrapper, but I find more often dropping empty
arguments is often very helpful after splits and suchlike.

But as to "${opts[@]}"...   Just too ugly to do that all the time, no?  Instead, use
zsh's awesome sticky emulation: 

    emulate zsh -c 'autoload -Uz ~/my-zsh-funcs/*'

Very helpful for insulating the risks of unexpected option settings, and makes it
safe to use unquoted variables.   As a rule of thumb, at least :-)






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