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 | 718b1d90e26311e132f042c7baee8d52f759fc76 (patch) | |
tree | fb7f80304e82a7b1a9129c236721fab549d128dd | |
parent | 52d0d799bc13907eb2fba67a0a50a99306f48867 (diff) | |
download | txr-718b1d90e26311e132f042c7baee8d52f759fc76.tar.gz txr-718b1d90e26311e132f042c7baee8d52f759fc76.tar.bz2 txr-718b1d90e26311e132f042c7baee8d52f759fc76.zip |
More reasonable fallback for self path: revisited.
This partially reverts and reworks commit
c5afb01548c5b6bf4ec83373b5e2e09f14690b01 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 |