Fixing scoping issue.

Accidentally used $dir inside a function, which caused an error.

Change-Id: Ic84ed69cab0abd889ff08a122f292d281e35e0d2