On Mon, May 2, 2016 at 1:59 PM, Grisha Levit <grishale...@gmail.com> wrote: > > On Mon, May 2, 2016 at 2:48 PM, Chet Ramey <chet.ra...@case.edu> wrote: >> >> and this one throws away the nameref attribute: >> >> typeset -n foo ; typeset -i foo ; foo=7*6 ; typeset -p foo > > > I think it's important to note that the nameref attribute is thrown away at > the `typeset -i foo' step, which makes some sense since `typeset -n -i' does > not seem to be valid in ksh.
ksh93 stores integer variables as actual integers internally so there's no opportunity for storing the expression, and the nameref attribute just wouldn't make sense. Bash stores a string that gets coerced as necessary when performing arithmetic. That's why ksh is so much faster than bash when you declare integers, and an integer will wrap around while a string will get converted back and fourth via pretty much the same rules bash uses. ~ $ ksh -c 'integer n=$(getconf LONG_MAX); typeset m=$n; ((m++,n++)); typeset -p n m' typeset -l -i n=-9223372036854775808 m=9.22337203685477581e+18 The only effect of -i in bash is to modify the way += assignments work.