diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-07-14 06:51:17 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-07-14 06:51:17 -0700 |
commit | d2c2c43ef008be06690b052d33ddb00627bacf8a (patch) | |
tree | fb7f80304e82a7b1a9129c236721fab549d128dd | |
parent | fea25125118435427c9ada388f629650e784286e (diff) | |
download | txr-d2c2c43ef008be06690b052d33ddb00627bacf8a.tar.gz txr-d2c2c43ef008be06690b052d33ddb00627bacf8a.tar.bz2 txr-d2c2c43ef008be06690b052d33ddb00627bacf8a.zip |
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.
-rw-r--r-- | txr.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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 |