Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: zsh -n does not detect incorrect associative array declaration
- X-seq: zsh-workers 38207
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Paul Wayper <paulway@xxxxxxxxxx>
- Subject: Re: zsh -n does not detect incorrect associative array declaration
- Date: Tue, 22 Mar 2016 17:20:56 -0700
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=hnw+gLDkRDk6OluL2iCOZvz/VLvuPqoNzuFO2vzCrQs=; b=B9UGBRsa5EbhrLPWtfdAsT+GnhIBq+vvygZEF5LoPwQr/khE/Ie7anw5zKW7XiTE+U bjRfhkyattRwc5ZgaMw6+fpcWCExyzvIa4+USC8Y64z2nTTsWHOre+FV3WxcG3LXszpw Rcjqf4btiaFoypcK1l0wOhBXB2vB8Tr2cV0EE0Mwn7WdChQj7N6SWcNQOyJMvS4DCqIu 2ijeCOnw0QrQapKu5Wa2n4R85JVY3Ma91Pw6nv+AINa7eui/tw9vWbmcyNyxyMruKqH3 MU9Lg960CeDDr8NZ5Mw4u9Q5mnP53n3Wb5S93ybwzG6aXLVMQyVrFvXBu7g5+90NMxnF nbkw==
- In-reply-to: <56F1C3D7.6020800@redhat.com>
- 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: <56F1C3D7.6020800@redhat.com>
On Tue, Mar 22, 2016 at 3:14 PM, Paul Wayper <paulway@xxxxxxxxxx> wrote:
>
> I've discovered that an incorrect associative array declaration in zsh
> isn't detected via 'zsh -n script.zsh', even though it does get flagged
> when the script is executed.
This is not a bug; it's something that it's impossible to check with
the NO_EXEC option. Consider:
typeset -a array
typeset -A fn
array=( $(some external command) )
fn=( $array )
With NO_EXEC set, the shell is prohibited from executing the $(some
external command) expression, so there is no way to determine how many
elements would be in $array if execution were allowed, and therefore
no way to determine whether an odd number of elements would be present
in the assignment to fn.
Technically, the shell is ALSO prohibited by NO_EXEC from executing
the "typeset" command, and therefore can't possibly know that "fn"
represents an associative array in the first place.
The NO_EXEC option is only useful for the most rudimentary of syntax
checks. It cannot detect/predict execution-time inaccuracies.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author