1 The `_` environment variable is a variable that is set by bash and some other
2 shells to point to the executable they use when executing a command. That is,
3 when executing `foo` from the command line, the shell sets `_` to
4 `/usr/bin/foo` (assuming that's where foo is).
6 However, nothing else does the same, so when e.g. a python program uses
7 `subprocess.Popen` to run another program, it doesn't set `_`. Worse, if that
8 python program itself was invoked from a shell, `_` would be set to e.g.
11 So when nsis is invoked from a program that is not a shell, but the process
12 ancestry has a process that was a shell, `_` may be set to the first
13 intermediary program rather than nsis, which defeats nsis's assumption that `_`
14 would contain the nsis path. Ironically, nsis also has more reliable fallbacks
15 (using e.g. /proc/self/exe), but somehow prefers `_`.
17 We remove the reliance of `_` entirely, for simplicity's sake.
20 diff -ruN nsis-3.07-src.orig/Source/util.cpp nsis-3.07-src/Source/util.cpp
21 --- nsis-3.07-src.orig/Source/util.cpp 2021-09-02 09:25:48.489016918 +0900
22 +++ nsis-3.07-src/Source/util.cpp 2021-09-02 09:26:21.158814484 +0900
25 return tstring(CtoTString(temp_buf));
26 #else /* Linux/BSD/POSIX/etc */
27 - const TCHAR *envpath = _tgetenv(_T("_"));
29 - return get_full_path(envpath);
32 char *path = NULL, *pathtmp;