One of the most frustrating and frequent scripting errors I make is in mistaking my current directory and improperly referencing another file or directory.

I have adopted a scope-like block style for changing directories using pushd and popd:

#!/bin/bash

mkdir lib/gdb
pushd lib/gdb
  sudo apt-get build-dep -y gdb
  sudo apt-get install -y libpython2.7 libpython2.7-dev

  apt-get source gdb

  pushd gdb-?.?.?
    ./configure \
      --with-python=$VIRTUAL_ENV/bin/python \
      --prefix=$VIRTUAL_ENV
    make
    make install
  popd
popd