Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] Strange auto-load behaviour when function name contains hyphen
- X-seq: zsh-workers 42122
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [BUG] Strange auto-load behaviour when function name contains hyphen
- Date: Thu, 14 Dec 2017 10:01:42 +0000
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20171214100147euoutp015833905d7380757eb7f140482e5d1379~AIPQQp01D3004830048euoutp01I
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1513245707; bh=qw9PyazesinwLhWOI394EydH0zwzUS2TOomV25nJXHo=; h=Date:From:To:Subject:In-reply-to:References:From; b=BKoJdm1V4vYDE6Gyh0y1bz2uyNqSbuSqeSHSQP/eP/7xOb085o7V5PWt9iIknJrpC VRZqsDv0ksKOwo2ykNkR9PKuK/X+tzQG7TZYiRaYBjZ+xQfeaS9cqqYVI/sqoIGbya eTGnuCpkGO+6rM59IZUaKXM1Mg7ys1qM61Vs4lvM=
- In-reply-to: <990A7EB2-C4BA-4E3D-99B3-7DA40846CBD1@dana.is>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <CGME20171214064805epcas2p196a185a6c3c5e66640833d8dfa15d593@epcas2p1.samsung.com> <990A7EB2-C4BA-4E3D-99B3-7DA40846CBD1@dana.is>
On Thu, 14 Dec 2017 00:46:29 -0600
dana <dana@xxxxxxx> wrote:
> The documentation states that function files intended for zsh-style
> auto-loading are allowed to contain a 'simple definition' (`foo() {
> ... }`) if that's the only thing in the file. This seems to work
> fine... except when the function name contains a hyphen.
A while back we had to turn "-" into a token to fix a compatibility
issue with pattern matching in POSIX shells. This has caused problems
to come out of the wardrobe ever since. ("Woodwork" implies a level
of solid material without the appropriate magical connotations.)
This has got line offsets including the function line numbering change as it
currently stands but I won't commit that.
pws
diff --git a/Src/exec.c b/Src/exec.c
index fc6d02d..5149349 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -5932,6 +5934,7 @@ stripkshdef(Eprog prog, char *name)
{
Wordcode pc;
wordcode code;
+ char *ptr1, *ptr2;
if (!prog)
return NULL;
@@ -5942,8 +5945,23 @@ stripkshdef(Eprog prog, char *name)
return prog;
pc++;
code = *pc++;
- if (wc_code(code) != WC_FUNCDEF ||
- *pc != 1 || strcmp(name, ecrawstr(prog, pc + 1, NULL)))
+ if (wc_code(code) != WC_FUNCDEF || *pc != 1)
+ return prog;
+
+ /*
+ * See if name of function requested (name) is same as
+ * name of function in word code. name may still have "-"
+ * tokenised.
+ */
+ ptr1 = name;
+ ptr2 = ecrawstr(prog, pc + 1, NULL);
+ while (*ptr1 && *ptr2) {
+ if (*ptr1 != *ptr2 && *ptr1 != Dash && *ptr1 != '-')
+ break;
+ ptr1++;
+ ptr2++;
+ }
+ if (*ptr1 || *ptr2)
return prog;
{
Messages sorted by:
Reverse Date,
Date,
Thread,
Author