Actually, it did work. But only for the script. The variables revert back to their previous values when you get back to the parent shell. That way, you can cd into a directory in your script, do something, and then not worry about getting back to where you started from.
If you want to keep the cd intact after you exit your script, try running the script with `source myscript.sh` instead of ./myscript.sh or `sh myscript.sh`.
<a target=_blank class=ftalternatingbarlinklarge href="http://www.linuxquestions.org/questions/linux-general-1/cd-keeps-snapping-back-to-current-directory-when-called-from-bash-script-357815/
">Text</a>