From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26557 invoked by alias); 23 Mar 2016 02:03:55 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 38207 Received: (qmail 23499 invoked from network); 23 Mar 2016 02:03:54 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) 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.1 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=hnw+gLDkRDk6OluL2iCOZvz/VLvuPqoNzuFO2vzCrQs=; b=U15HEBbOSLUsTQzxyR9Vfz4cAmWdKlf9xPagld121C1QzNByUpNA8sI8fpDPw2RORN nKrq1QO57oLevEFVcKyMMaDPve8m5nfmUWIz5xiG81IPJEVPCpkLihwvjJxiqpDlbMOY 4QEFPvxQOk64D9nLGOLW86TF1Kj+ql7rmD6XQznW6KUUnmJ493NHhg74kr+UCPXHY9Q3 u3QRmUy7zS4jm7tSqd3naqOAXBKIxf5BHFqDJW1fRhf9YBY/lwMgCZ+bmfj7qqsP8tDr Lsb9jSoHefeQKMch5rnLTYChiGXar6Ykp14QwOjGyc2Dne29GKi46M7cpdes4zUHzNpa GMjw== X-Gm-Message-State: AD7BkJJwNYBbc4PFpp452AIEvdzZ5FSbtIo9oRfYftOhFHKFI7X+v7u2edZZpCm39tPoy6kiOoPxqIcteNwYmQ== MIME-Version: 1.0 X-Received: by 10.194.116.9 with SMTP id js9mr45444976wjb.112.1458692456435; Tue, 22 Mar 2016 17:20:56 -0700 (PDT) In-Reply-To: <56F1C3D7.6020800@redhat.com> References: <56F1C3D7.6020800@redhat.com> Date: Tue, 22 Mar 2016 17:20:56 -0700 Message-ID: Subject: Re: zsh -n does not detect incorrect associative array declaration From: Bart Schaefer To: Paul Wayper Cc: Zsh hackers list Content-Type: text/plain; charset=UTF-8 On Tue, Mar 22, 2016 at 3:14 PM, Paul Wayper 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.