aboutsummaryrefslogtreecommitdiffstats
path: root/erts/etc
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2017-02-06 16:44:36 +0100
committerRickard Green <[email protected]>2017-02-06 16:44:36 +0100
commit77a9b8c6fe331761a89d48419ee2200ba5377e49 (patch)
tree3501f991ff694c7550d85abcbf49e6ed1885d198 /erts/etc
parentbf24d74c27b8773ac3d3c6f970df04098fa74c21 (diff)
parent1d8dbc7123245a536df6bb09e891d3a075fb70ed (diff)
downloadotp-77a9b8c6fe331761a89d48419ee2200ba5377e49.tar.gz
otp-77a9b8c6fe331761a89d48419ee2200ba5377e49.tar.bz2
otp-77a9b8c6fe331761a89d48419ee2200ba5377e49.zip
Merge branch 'hm/escript-emulator'
OTP-14201 * hm/escript-emulator: escript: Handle symbolic link to a standalone escript
Diffstat (limited to 'erts/etc')
-rw-r--r--erts/etc/common/escript.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/erts/etc/common/escript.c b/erts/etc/common/escript.c
index 71c278881c..4134a3ff36 100644
--- a/erts/etc/common/escript.c
+++ b/erts/etc/common/escript.c
@@ -428,14 +428,6 @@ main(int argc, char** argv)
argv[argc] = NULL;
#endif
- emulator = env = get_env("ESCRIPT_EMULATOR");
- if (emulator == NULL) {
- emulator = get_default_emulator(argv[0]);
- }
-
- if (strlen(emulator) >= PMAX)
- error("Value of environment variable ESCRIPT_EMULATOR is too large");
-
/*
* Allocate the argv vector to be used for arguments to Erlang.
* Arrange for starting to pushing information in the middle of
@@ -446,21 +438,10 @@ main(int argc, char** argv)
eargv_base = (char **) emalloc(eargv_size*sizeof(char*));
eargv = eargv_base;
eargc = 0;
- push_words(emulator);
eargc_base = eargc;
eargv = eargv + eargv_size/2;
eargc = 0;
- free_env_val(env);
-
- /*
- * Push initial arguments.
- */
-
- PUSH("+B");
- PUSH2("-boot", "start_clean");
- PUSH("-noshell");
-
/* Determine basename of the executable */
for (basename = argv[0]+strlen(argv[0]);
basename > argv[0] && !(IS_DIRSEP(basename[-1]));
@@ -510,6 +491,27 @@ main(int argc, char** argv)
efree(absname);
}
+ /* Determine path to emulator */
+ emulator = env = get_env("ESCRIPT_EMULATOR");
+
+ if (emulator == NULL) {
+ emulator = get_default_emulator(scriptname);
+ }
+
+ if (strlen(emulator) >= PMAX)
+ error("Value of environment variable ESCRIPT_EMULATOR is too large");
+
+ /*
+ * Push initial arguments.
+ */
+
+ push_words(emulator);
+ free_env_val(env);
+
+ PUSH("+B");
+ PUSH2("-boot", "start_clean");
+ PUSH("-noshell");
+
/*
* Read options from the %%! row in the script and add them as args
*/