2

Input: range 6

function range {
        echo {0..$1}
        echo {0..6}
        if [[ $1 =~ 6 ]]
        then
          echo "Equal"
        fi
}

Output:

{0..6}

0 1 2 3 4 5 6

Why is the output different whereas $1 and 6 is equal?

Toto
  • 89,455
  • 62
  • 89
  • 125
NobinPegasus
  • 545
  • 2
  • 16

1 Answers1

0

The curly-braces get expanded before $-variables are expanded, and the curly-brace range syntax simply doesn't recognize anything other than a pair of numbers with dots in between.

zeroimpl
  • 2,746
  • 22
  • 19