Add a utility function to trim strings
Bug fix to commands: tokenise proc name correctly

Previously the nicely tokenised command name during command execution
was being clobbered by a vanilla >> with a stringstream. In certain
cases (e.g quotes generated during command substitution) this could
caused the proc lookup to fail.

This has now been fixed.