[lsb-discuss] readlink

Craig.Scott at csiro.au Craig.Scott at csiro.au
Thu Feb 17 16:36:19 PST 2011


Hi all. While looking for a way to robustly get the real name/path of a script being run (ie find what $0 really points to in a shell script), I came across lots of posts that recommend the readlink command. Firing up the LSB navigator, I can see that all of the linux distributions the navigator covers seem to offer the readlink command except some PPC32 and S390 distributions, but readlink is not in any LSB version for any platform. I was just wondering if anyone has looked at this before and whether there are reasons why those few platforms don't offer readlink? I can understand that while some don't offer it, the inclusion of readlink in the LSB would be hard to justify (ie confusion over some platforms supporting it and not others).

About the most direct LSB-compliant alternative I've found to readlink so far is via perl:

perl -e 'print readlink($ARGV[0]) . "\n"'

While the above works, I'd hardly say that it is "user friendly" compared to readlink, which is much more direct. It's also not ideal having to fire up perl just for something as simple as this.

--
Dr Craig Scott
Computational Software Engineering Team Leader, CSIRO (CMIS)
Melbourne, Australia






More information about the lsb-discuss mailing list