and...@coolbox.se wrote:
> On Thu, Apr 18, 2013 at 12:02:55PM -0500, Dan Douglas wrote:
>> 10 factorial (bash/ksh93/zsh):
>>
>> $ f=n=n?n--*f:1 let n=10 f
> bash: let: n=n?n--*f:1: expression recursion level exceeded (error token is
> "n?n--*f:1")
>> $ echo "$n"
> 0
---
Hmmm...works here
OK. So, the various other [nested] expansions happen first.
That explains the phenomenon. I still don't quite understand
why this is desirable (other than possibly ease of programming),
but that's fine, too. Why do all the extra work, when the results
aren't going to be used? The answer must be
Arithmetic operators short-circuit just as in C. The rules for arithmetic
apply only to the actual arithmetic evaluation step. Arithmetic contexts
evaluate expressions derived from the results of prior expansions. Think of
shell arithmetic as a mini-language.
`a' becomes 10 here, because the si
On 4/18/13 10:40 AM, Greg Wooledge wrote:
> The order of expansions is: brace expansion, tilde expansion,
> parameter, variable and arithmetic expansion and command substitution
> (done in a left-to-right fashion), word splitting, and pathname
> expansion.
>
> It's not cle
On Thu, Apr 18, 2013 at 11:59:40AM +0200, and...@coolbox.se wrote:
> The ARITHMETIC EVALUATION section of the man page claims equivalence with C
> for all the operators, but in reality bash does not perform short circuit
> evaluation, which implies that the logical operators do NOT produce the same
On Thu, Apr 18, 2013 at 5:36 PM, Pierre Gaston wrote:
>
>
>
> On Thu, Apr 18, 2013 at 12:59 PM, and...@coolbox.se wrote:
>
>> The ARITHMETIC EVALUATION section of the man page claims equivalence with
>> C for all the operators, but in reality bash does not perform short circuit
>> evaluation, whic
On Thu, Apr 18, 2013 at 12:59 PM, and...@coolbox.se wrote:
> The ARITHMETIC EVALUATION section of the man page claims equivalence with
> C for all the operators, but in reality bash does not perform short circuit
> evaluation, which implies that the logical operators do NOT produce the
> same resu
The ARITHMETIC EVALUATION section of the man page claims equivalence with C for
all the operators, but in reality bash does not perform short circuit
evaluation, which implies that the logical operators do NOT produce the same
results as in C.
Try these, for example:
f () {
# echo "$@" >&2