[j-nsp] initialize multiple mutable variables in SLAX with the same value

Martin T m4rtntns at gmail.com
Tue Mar 6 10:44:57 EST 2018


Hi!

I would like to initialize multiple mutable variables with the same
value. I could initialize variables one by one like this:

mvar $c1 = 0;
mvar $c2 = 0;
mvar $c3 = 0;
mvar $c4 = 0;
mvar $c5 = 0;
mvar $c6 = 0;
mvar $c7 = 0;

However, is there a better way? My first idea was to use a loop.
Something like this:

for $i (1 ... 7) {
  mvar $c _ $i = 0;
}

..but as I expected, this does not work. For example in bash, I would do:

for i in {1..7}; do
  set c"$i"=0
done

..or use an array like this: "for i in {1..7}; do c[i]=0; done".


thanks,
Martin


More information about the juniper-nsp mailing list