From d2c2c43ef008be06690b052d33ddb00627bacf8a Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 14 Jul 2020 06:51:17 -0700 Subject: More reasonable fallback for self path: revisited. This partially reverts and reworks commit c6053a7e8e8d37dbab3926cfaf4e04a1d136c87a from May 4, 2018. I have no idea why I replaced fallback code which does something quite reasonable: invokes realpath on the value from argv[0]. The commit comment claims that this breaks when the program is not invoked with an absolute path, but how can that be, if realpath is used? * txr.c (get_self_path): Let's keep TXR_INST_PATH, and return that in the case that progname_u8 is null, because of a null argv[0]. Otherwise, let's revert to the original strategy of calling realpath on progname_u8. --- txr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/txr.c b/txr.c index 760b7814..43471029 100644 --- a/txr.c +++ b/txr.c @@ -259,6 +259,11 @@ static val get_self_path(void) #else static val get_self_path(void) { + char self[PATH_MAX]; + + if (progname_u8 && realpath(progname_u8, self)) + return string_utf8(self); + return lit(TXR_INST_PATH); } #endif -- cgit v1.2.3