From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25390 invoked by alias); 19 Dec 2014 03:58:41 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19584 Received: (qmail 19410 invoked from network); 19 Dec 2014 03:58:38 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Message-ID: <54939F50.50102@gmx.com> Date: Thu, 18 Dec 2014 22:45:20 -0500 From: Eric Cook User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: zsh-users@zsh.org Subject: Could someone clarify how math functions work? Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:YfrDlcvmEcBq9kH+71pYc8M0UhGbXbybmWdeQYlC+EpWSPxYS3T 91HNL1tJs0dvXCQH689aKfSWTmwJ0dSuLFH6hD96x24aUoYEYmGPjsQ9e9Vbi1BRKg2efLR yXX/UfLECVgi7J+jJR7XWjXcmiubj229B4D64lRRH0fCZadR7f1xZYe0jkbj9HbvkB5AjOP RAwhE+niBGEXOCBuOsdiQ== X-UI-Out-Filterresults: notjunk:1; In the `functions -M' section of zshbuiltins there is the sentence: "The result of the last arithmetical expression evaluated inside the shell function (even if it is a form that normally only returns a status) gives the result of the mathematical function." but: zsh -c 'add() ( for arg; do (( n += arg )); done; print n: $n ); functions -M add; print results: $(( add(1,2,3) ))' Outputs: n: 6 results: 3 where as: zsh -c 'add() { local arg n; for arg; do (( n += arg )); done; print n: $n }; functions -M add; print results: $(( add(1,2,3) ))' Outputs: n: 6 results: 6 Is that expected behavior? If so, could you explain why?