Re: Found problem mentioned in email 3/27: path interpretted/eval'd as numeric expression

2013-04-18 Thread Linda Walsh
Chris Down wrote: > On 2013-04-17 17:30, Linda Walsh wrote: >> BTW, is it planned to implement exporting ARRAY and HASHES? >> >> Sure would simplify some programs... ;-) > > As if exporting functions wasn't hacky enough... But then the function would have produced consistent results

Re: Logical operators in arithmetic evaluation: documentation vs implementation

2013-04-18 Thread Linda Walsh
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

Re: Logical operators in arithmetic evaluation: documentation vs implementation

2013-04-18 Thread andras
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

Re: Logical operators in arithmetic evaluation: documentation vs implementation

2013-04-18 Thread Dan Douglas
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

Re: Logical operators in arithmetic evaluation: documentation vs implementation

2013-04-18 Thread Chet Ramey
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

Re: Logical operators in arithmetic evaluation: documentation vs implementation

2013-04-18 Thread Greg Wooledge
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

Re: Logical operators in arithmetic evaluation: documentation vs implementation

2013-04-18 Thread Pierre Gaston
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

Re: Logical operators in arithmetic evaluation: documentation vs implementation

2013-04-18 Thread Pierre Gaston
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

Logical operators in arithmetic evaluation: documentation vs implementation

2013-04-18 Thread and...@coolbox.se
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