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

Re: view onto command pipeline?



On Wed, Jul 20, 2022, at 8:35 AM, Dominik Vogt wrote:
> On Wed, Jul 20, 2022 at 02:22:21PM +0200, Vincent Bernat wrote:
>> On 2022-07-20 13:37, Dominik Vogt wrote:
>> > For proper handling of whitecpace in options and arguments:
>> >
>> >    command git "${opts[@]}" "$@"
>> >
>> > Otherwise, if you have, say, files "a", "b" and "a b",
>> >
>> >    $ git commit "a b"
>> >
>> > Would commit a and b but not "a b" if the $@ is not quoted.  As a
>> > rule of thumb, _never_ use unquoted variables in shell scripts.
>>
>> I don't think this is true for Zsh.
>
> Depends on shell options:

Additionally, without quoting empty words are removed.

    % foo=                                
    % bar=(a '' 'b c')                    
    % printf '<%s>' "$foo" "$bar[@]"; echo
    <><a><><b c>
    % printf '<%s>' $foo $bar[@]; echo    
    <a><b c>

Whether or not this is desirable is up to the application.

-- 
vq




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