Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;
        h=from:message-id:date:in-reply-to:comments:references:to:subject
         :mime-version:content-type;
        bh=67nWwSxYTNS7ewj23Q+hJyKzToZ6XtLsEMYS5aHy398=;
        b=D8PwNDCRePv7bjU7Z0wOmc8+8mULIJoQElu11XSitpWdpf9HC20hr0ulQqwQlkwZLV
         Mu6yhUpilnXcJ+9+teZQzeoKABCp5gsGSA5/EkXa+14aaEp+oxloou+VVRciahZs40Ef
         zosAu+fqgiZHLrnXWldY4yGsw2AMlolriJ/+KJ60QdcuKGQKz8kbsExRd94kJ7FyAlcY
         HFICqIkQfck7sdrhsOd4InArVq4oCj5S13nOm4B+vIyzxQsAuuLKEyfbzdrjplul41DN
         mldukCatVIIBqHOt9ZlxEboUHtyorxOmKba6tR3c+93Eydr+hqJtW5hFPF1hdwxfWrRy
         Lu/w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:date:in-reply-to:comments
         :references:to:subject:mime-version:content-type;
        bh=67nWwSxYTNS7ewj23Q+hJyKzToZ6XtLsEMYS5aHy398=;
        b=Ilxh+sECplpHZrehv8aYquWcxgycQdsyKYyC2b61OBvhWAsFJolQj7CpTZYNGeebZt
         5bRtcGXuXi0pVJQxh6dp/BaX/TgwkgACYLtXe238uEvEQPxg5Av6RXP7xpWpWKUvtJqQ
         DNL7Fs2pCUP3gKMa11B7UcPUAhlAPTXHRD88Mq6nAn23dDBkEyyuJjHiDp0h1GAuWLCr
         8/EWEaIH73SXKkHMeLRXfV0EtKR6Lejk3mSDpBsTX7JywoqTTe1u5r7AOB5+uypsdoms
         JrGN83GiU5hR5TWwUreK+b1Px7uncCTptuelcJBmeujIQ/EFUVwh+PczTUjBCAnJedxw
         5Nzw==
X-Gm-Message-State: AG10YOTbZx8eni85aGS+CEj/RONFqlpUATKmnJY/hDXJ4HMrTMJeZJVvHvxEuXVLu4NDOw==
X-Received: by 10.66.197.131 with SMTP id iu3mr2133419pac.57.1453963082575;
        Wed, 27 Jan 2016 22:38:02 -0800 (PST)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160127223847.ZM17546@torch.brasslantern.com>
Date: Wed, 27 Jan 2016 22:38:47 -0800
In-Reply-To: <CAKc7PVB+wqm2t83obgqop3xAyXtiBSw+z_yVkhOZcFTvHzwxAQ@mail.gmail.com>
Comments: In reply to Sebastian Gniazdowski <sgniazdowski@gmail.com>
        "Re: Proof of concept mainstream plugin manager" (Jan 27,  8:34am)
References: <CAKc7PVByfo51GcVkb_kYgO2D3cWYrcq-p4v8gmyfsaeWU=2new@mail.gmail.com> 
	<160122173705.ZM11491@torch.brasslantern.com> 
	<CAKc7PVCywh3fVsvFOUP3Bi27-8o1w30_E73rs8c+Zd4sOqtT8w@mail.gmail.com> 
	<CAKc7PVChdTs4WzKf+amXJ9Y7zOpQVSEsVm6pmHK3FcCQy5k-Xw@mail.gmail.com> 
	<CAKc7PVD-AAQ2TDQ_V06Sh15xT9=n5u+cU1WXRAk4kGAi16DqPA@mail.gmail.com> 
	<CAKc7PVCXvW0PCV_pREMBqvWvVL02qFmnvc+PMcdDArrCuDMjpg@mail.gmail.com> 
	<160123093602.ZM14454@torch.brasslantern.com> 
	<160123112004.ZM14739@torch.brasslantern.com> 
	<160123120055.ZM14828@torch.brasslantern.com> 
	<20160126225010.GA15958@tarsus.local2> 
	<160126203458.ZM2800@torch.brasslantern.com> 
	<CAKc7PVB+wqm2t83obgqop3xAyXtiBSw+z_yVkhOZcFTvHzwxAQ@mail.gmail.com>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Proof of concept mainstream plugin manager
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 37820

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.

