So, I wrote unit tests, a simple Makefile and documentation: man page, README, INSTALL, stuff like that.
Kevin, wiser than I, looked and found documentation that suggested readlink -f would do the trick. And it does. I could prove it to myself because I had unit tests.
One difference in functionality, which I can live with: if the file is missing, readlink -f succeeds and reports it's in the current directory.
So, to find the path to an executable, this does the trick:
path2 () {
local _cmd=$(type -p $1)
[ -f $_cmd ] && readlink -f $_cmd
}
No comments:
Post a Comment