[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## Re: [Help-bash] Arithmetic evaluation / expansion question

**From**: |
Greg Wooledge |

**Subject**: |
Re: [Help-bash] Arithmetic evaluation / expansion question |

**Date**: |
Wed, 10 Oct 2018 13:07:46 -0400 |

**User-agent**: |
NeoMutt/20170113 (1.7.2) |

On Wed, Oct 10, 2018 at 12:47:05PM -0400, Bruce Hohl wrote:
>* Are strings also evaluated to zero within $(( ))?*
>* *
>* $ pd=abc*
>* $ echo $pd*
>* abc*
>* $ echo $((pd))*
>* 0*
As Andy said, things that can be parsed as variable names are treated
as variable names in arithmetic contexts. What he didn't mention was
that bash does this *recursively* until it gets to an integer, or to
something that can't be parsed as either an integer or a variable name.
wooledg:~$ a=b b=c c=d d=e e=f f=42; echo $((a))
42

**[Help-bash] Arithmetic evaluation / expansion question**, *Bruce Hohl*, `2018/10/10`
**Re: [Help-bash] Arithmetic evaluation / expansion question**, *Andy Chu*, `2018/10/10`
**Re: [Help-bash] Arithmetic evaluation / expansion question**,
*Greg Wooledge* **<=**
**Re: [Help-bash] Arithmetic evaluation / expansion question**, *Andy Chu*, `2018/10/10`
**Re: [Help-bash] Arithmetic evaluation / expansion question**, *Andy Chu*, `2018/10/10`
**Re: [Help-bash] Arithmetic evaluation / expansion question**, *Bruce Hohl*, `2018/10/10`
**Re: [Help-bash] Arithmetic evaluation / expansion question**, *Andy Chu*, `2018/10/10`
**Re: [Help-bash] Arithmetic evaluation / expansion question**, *Bruce Hohl*, `2018/10/10`
**Re: [Help-bash] Arithmetic evaluation / expansion question**, *Quentin L'Hours*, `2018/10/10`
**Re: [Help-bash] Arithmetic evaluation / expansion question**, *Bruce Hohl*, `2018/10/10`
**Re: [Help-bash] Arithmetic evaluation / expansion question**, *Chet Ramey*, `2018/10/11`
**Re: [Help-bash] Arithmetic evaluation / expansion question**, *Chet Ramey*, `2018/10/11`

**Re: [Help-bash] Arithmetic evaluation / expansion question**, *Chet Ramey*, `2018/10/11`