yea well i posted in a later post, locally declared vars are empty excepts they are given on the function calling line, just like local vars, hm the different names is not so a good idea but ill think
thank you much anyway :)) On Mon, Mar 8, 2021 at 2:25 AM Greg Wooledge <g...@wooledge.org> wrote: > Alex fxmbsw7 Ratchev (fxmb...@gmail.com) wrote: > > bash-5.1# cat int.fail > > int() { > > declare -a int > > You've declared a local array named "int" which has nothing in it. > > This is inside a function named "int". > > > declare i=-1 now > > > > while [[ -v int[++i] ]] && now=${int[i]} ; do > > printf %s\\n "$now" > > done > > } > > You're iterating on the empty local array. > > > > > int=( a b c ) > > int > > You also have a global array named "int". > > I suggest that you use different names for your stuff. This will help > you avoid a lot of problems. Having a global variable, a local variable, > and a function all sharing the same name (and a name which is actively > *misleading* given that one of the arrays does not, in fact, contain > integer values) is not helping you. > >