replace pushd/popd commands

as they are not avail on all distributions (eg ubuntu)
Merge pull request #1265 from breznak/fix_pushd_popd

replace pushd/popd commands