‘Shell’ Archive

Loop variable collisions in Bash 2016-04-30 No Comments

Let’s have a look at this simple Bash script: #! /bin/bash inner() { for i in {1..4}; do echo ” $i” done } outer() { for i in {1..3}; do echo “$i” inner done } outer The output is .. 1 1 2 3 4 2 1 2 3 4 3 1 2 3 4 […]