On Mon, Feb 16, 2009 at 10:50 AM, Sebastian Nowicki <[email protected]> wrote: > > On 16/02/2009, at 6:25 PM, Xavier wrote: > >> Before moving forward, I have a question : >> is there any good and portable way to convert between absolute and >> relative paths? >> I don't see any reason for doing any symlinks resolution anywhere. >> The only thing we need is to convert a given path (which can be either >> absolute or relative) to an absolute path. >> We need this because we are changing directories, and these paths have >> to stay valid so have to be absolute. > > After a bit of Googling I haven't been able to find a solution. On the > contrary, many posts indicate that there is no cross-platform way - at least > not without introducing huge dependencies (python/ruby/etc). It's weird > considering that there's a standard C function[1] which does exactly this. A > semi-ugly solution would be to provide an executable which simply calls this > function, as part of the pacman package. However, if the speed difference is > not that important, the bash implementation is a nicer solution. > > [1]: http://www.opengroup.org/onlinepubs/000095399/functions/realpath.html >
That's so crazy and disappointing.. But well, since we are considering to implement our own thing in bash, maybe we could just go with a simpler bash function that just builds the absolute path? I saw several implementations in bash using a combination of dirname, basename, cd and pwd. Hopefully these 4 tools are portable. Otherwise dirname and basename can be reimplemented as well without too much complexity. _______________________________________________ pacman-dev mailing list [email protected] http://www.archlinux.org/mailman/listinfo/pacman-dev
