Portable implementation of the 'which' utility