aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2017-05-22 15:49:15 +0200
committerRickard Green <[email protected]>2017-05-23 17:45:47 +0200
commit68de330d763fb450a763a2d56e63dbe009e12703 (patch)
tree148b9a91c8c90a8489d580581b79b3bba809af62 /erts
parent3e42bb4feb6a3a90895595d53b37092f699ba4c3 (diff)
downloadotp-68de330d763fb450a763a2d56e63dbe009e12703.tar.gz
otp-68de330d763fb450a763a2d56e63dbe009e12703.tar.bz2
otp-68de330d763fb450a763a2d56e63dbe009e12703.zip
Fix erlang system lookup from escript bug introduced in PR #1293
Erlang system found in PATH was used even when explicitly pointing out the escript binary in another Erlang system.
Diffstat (limited to 'erts')
-rw-r--r--erts/etc/common/escript.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/erts/etc/common/escript.c b/erts/etc/common/escript.c
index 630e241882..80cc25b040 100644
--- a/erts/etc/common/escript.c
+++ b/erts/etc/common/escript.c
@@ -433,7 +433,7 @@ main(int argc, char** argv)
char* emulator;
char* env;
char* basename;
- char* absname;
+ char* def_emu_lookup_path;
char scriptname[PMAX];
char** last_opt;
char** first_opt;
@@ -480,6 +480,7 @@ main(int argc, char** argv)
#else
if (strcmp(basename, "escript") == 0) {
#endif
+ def_emu_lookup_path = argv[0];
/*
* Locate all options before the script name.
*/
@@ -498,27 +499,24 @@ main(int argc, char** argv)
argc--;
argv++;
} else {
+ char *absname = find_prog(argv[0]);
#ifdef __WIN32__
- int len;
-#endif
- absname = find_prog(argv[0]);
-#ifdef __WIN32__
- len = strlen(absname);
+ int len = strlen(absname);
if (len >= 4 && _stricmp(absname+len-4, ".exe") == 0) {
absname[len-4] = '\0';
}
#endif
-
erts_snprintf(scriptname, sizeof(scriptname), "%s.escript",
absname);
- efree(absname);
+ efree(absname);
+ def_emu_lookup_path = scriptname;
}
/* Determine path to emulator */
emulator = env = get_env("ESCRIPT_EMULATOR");
if (emulator == NULL) {
- emulator = get_default_emulator(scriptname);
+ emulator = get_default_emulator(def_emu_lookup_path);
}
if (strlen(emulator) >= PMAX)