Suppose I'm running bash on a Unix-ish system - not necessarily Linux and not necessarily very new; and it may not have every bit of software I'd like.
Now, I have a relative path for which I want to get the absolute path. What's the most robust and portable way of doing this?
The answers here seem to mostly assume the GNU core utilities are installed, which I would rather not do.
Bonus points if your answer works on any Bourne Shell variant.
pwd
and changing dirs(and it's funny that you want a robust way to get absolute paths but didn't said changing dirs were allowed, and also considered this "safer" than install gnureadlink
) is to make a little utility inC
usingrealpath()
function - https://stackoverflow.com/a/229038/2231796 – Jun 20 '17 at 18:54