Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: ${(z)} split of unmatched, doubled ((
- X-seq: zsh-workers 36666
 
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
 
- To: zsh-workers@xxxxxxx
 
- Subject: Re: ${(z)} split of unmatched, doubled ((
 
- Date: Sun, 27 Sep 2015 17:59:06 -0700
 
- In-reply-to: <20150927235106.GD1879@tarsus.local2>
 
- List-help: <mailto:zsh-workers-help@zsh.org>
 
- List-id: Zsh Workers List <zsh-workers.zsh.org>
 
- List-post: <mailto:zsh-workers@zsh.org>
 
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
 
- References: <20150927012337.GD1989@tarsus.local2> 	<150927090048.ZM25706@torch.brasslantern.com> 	<20150927235106.GD1879@tarsus.local2>
 
On Sep 27, 11:51pm, Daniel Shahaf wrote:
} Subject: Re: ${(z)} split of unmatched, doubled ((
}
} Since the "two subshells" case can be disambiguated by adding a space,
} but arithmetic evluations cannot be disambiguated, I assume ambiguous
} cases should be resolved in favour of the latter.
} 
} I see the problem: ${(z)} is bufferwords(), which calls ctxtlex(), which
} ultimately calls cmd_or_math(), which classifies the unbalanced opening
} parentheses as a syntax error, because they have no matching ')' before
} the end of the input.  Consequently, cmd_or_math() returns CMD_OR_MATH_ERR
} on line 512 (in the 'if (lexstop)' block), which causes ctxtlex() to
} return LEXERR.
So perhaps this:
diff --git a/Src/lex.c b/Src/lex.c
index 70f3d14..6eb3c82 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -785,6 +785,8 @@ gettok(void)
 		    return INPAR;
 
 		default:
+		    if (lexflags & LEXFLAGS_ACTIVE)
+			tokstr = dyncat("((", tokstr);
 		    return LEXERR;
 		}
 	    }
It might be prudent to also test that tokstr != NULL there, but I have
not found a sample input where that occurs.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author