      SRC=/path/to/foo.c
      BASE=${SRC##*/}
      DIR=${SRC%"$BASE"}

some notes about the `#/%` syntax:

- The thing you're stripping is a shell glob, not a regex. So "", not "."
  bash has a handy regex version of this, but we're not talking about bashisms
  here :)
- The part you want to remove can include shell variables (using $).
- Unfortunately the part you're removing from has to be just a variable name,
  so you might have to strip things in a few steps. In particular, removing
  prefixes and suffixes from one string is a two step process.
- There's also `##/%%`, which mean "the longest matching prefix/suffix" and
  `#/%` mean "the shortest matching prefix/suffix." So to remove the first
  directory only, you could use `SUB=${SRC#*/}`.
