Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
When is a pre-command assignment syntactically valid?
- X-seq: zsh-users 23000
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: When is a pre-command assignment syntactically valid?
- Date: Wed, 6 Dec 2017 23:23:05 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=AeSDgdBrIuZP30uEGKWFBsCXFXtqW VZ5rxntDpVEfvU=; b=iT+bpl9hZVbG6kT91OIx8u9MnDJLSlI4WvISpWmtTbiEp xPHO7oG6jgsKrvOEmodWsuZn2LnGROXWiBaVC/7JD/sRuH83EQ4J9P50+JujYlit 7G1rJuD3Ui/AwrMQ2ibyrctEC/o/9MymQETJJ8kRtHsk+rGK5J1eqJlOBEtOZB7t ZA6pWODeV7t2DkLNTFdEiytVFwj6rqRi3ccXk0Iwc+oWC2KpxTWnTuE5ASRMcxAa li1wSSabxWvuSSG/odK/LXUQmNXJmSG/7etS5VlbbVM6cnLmnFYDTJ3RmrEkvLki rqdDpFrqpl9SrJu2k8MQNt7LYAmufeiWLJrPh0/hQ==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=AeSDgdBrIuZP30uEGKWFBsCXFXtqW VZ5rxntDpVEfvU=; b=QkDaDql8FvSVkQZdx3/iQtfaynsPctolxk67ML3HMIiw1 Y9vIIUuaDhPIpm+HmMOUbchqTQr2WEcDFvIh5SnfUNxeJBr1pmyA9I/2lB1BmFXQ P5H6MIkgk8qCsZw4jGU7f9cm5w/zCXKaG0C2Qiqt99z+0U3OtDcYVQLoRai13m2+ Fz5W2yIKFcjEk0k7AkLJtqnNmRGSMB6tbZhcp5wZmUcR98V/8Lb6tsuPSnGHLMOT epb7/KeYS/d4n7+HTUCU6vVtIyrGTrIgfCp1j1I63RKNaaVBvLw7hfjPIJFkKl4+ b5cFF7MgDeeZFozD59eplh0jvb+39Sfcec3ruTiNA==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
In z-sy-h we're trying to determine in what circumstances an assignment is
valid before a command.¹
Empirically, when an assignment is followed by one of the reserved words
«((» «[[» «(» «{» «!»
a parse error results, but when an assignment is followed by the name of a
command, builtin, or function, execution succeeds. It doesn't seem to matter
whether the assigned parameter is a scalar or an array. (Of course, setting
an array in front of an external command, as in «a=(foo bar) /bin/true», isn't
necessarily _useful_ — barring 'typeset -T' and hooks — but it's syntactically
valid, which is z-sy-h's concern.)
So, I think the rule is: "reserved words may not be preceded by parameter
assignments". Is that accurate?
Thanks,
Daniel
P.S. Incidentally, I can see how it might be useful to allow assignments before
some of these constructs (e.g., «foo=bar (subshell; commands;)»), but I'm not
advocating for that; I'm just trying to grok the status quo so z-sy-h can
support it.
¹ https://github.com/zsh-users/zsh-syntax-highlighting/issues/461
Messages sorted by:
Reverse Date,
Date,
Thread,
Author