When the bash script exits, you're back where you started because the
process executing the script terminated. :-)
The "cd ~/avr" does work in the script; add a "pwd" between that and
the "exit 0" to reassure yourself.
If you want to actually remain in ~/avr when the script finishes,
remove the "exit 0" and start the script per "source scriptname"
or ". scriptname" (noting there's a space between the "." and the
scriptname.