[Issue 16595] thisExePath resolves symlinks but this isn't mentioned in docs

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Dec 16 00:13:12 PST 2016


https://issues.dlang.org/show_bug.cgi?id=16595

Jacob Carlborg <doob at me.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doob at me.com

--- Comment #1 from Jacob Carlborg <doob at me.com> ---
The implementation of "thisExePath" on macOS calls "realpath". The intention is
to get the full path without any extra "/", "." or "..". Removing the call to
"realpath" from "thisExePath" resolves in the following behavior:

$ ./d/main
/Users/jacob/development/./d/main

The Linux implementation is using "readlink" to read "/proc/self/exe". This
resolves symbolic links as well. I don't know any other way to do it on Linux.
So the behavior of macOS and Linux is at least consistent. I don't remember the
behavior of the other platforms when it comes to symbolic links.

The workaround would be to implement "thisExePath" yourself. That is,
copy-paste the implementation of the existing "thisExePath" and remove the call
to "realpath". Perhaps add a call to "asNormalizedPath" if you want to remove
any extra "/", "." and ".."

--


More information about the Digitalmars-d-bugs mailing list