zsh-users
 help / color / mirror / code / Atom feed
* Could someone clarify how math functions work?
@ 2014-12-19  3:45 Eric Cook
  2014-12-19  5:16 ` Kurtis Rader
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Eric Cook @ 2014-12-19  3:45 UTC (permalink / raw)
  To: zsh-users

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?


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-12-19 11:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-19  3:45 Could someone clarify how math functions work? Eric Cook
2014-12-19  5:16 ` Kurtis Rader
2014-12-19  5:34 ` Bart Schaefer
2014-12-19  5:48   ` Kurtis Rader
2014-12-19  5:51     ` Kurtis Rader
2014-12-19  6:05     ` Bart Schaefer
2014-12-19 11:15   ` Eric Cook
2014-12-19  9:35 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).