Fix shell variable scope