diff options
author | Siri Hansen <[email protected]> | 2013-03-19 14:41:43 +0100 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2013-04-03 12:24:07 +0200 |
commit | 1e25a41af35e6dea65166bbc2d5f0c4c1433ffee (patch) | |
tree | 9e70818a107551947e9646544ee3fbfd992fafcb | |
parent | 0841aaf3a09b4ddcf5ea52a6c781f5e11cf85227 (diff) | |
download | otp-1e25a41af35e6dea65166bbc2d5f0c4c1433ffee.tar.gz otp-1e25a41af35e6dea65166bbc2d5f0c4c1433ffee.tar.bz2 otp-1e25a41af35e6dea65166bbc2d5f0c4c1433ffee.zip |
Quote path to erl executable in slave to allow space in path
-rw-r--r-- | lib/stdlib/src/slave.erl | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/stdlib/src/slave.erl b/lib/stdlib/src/slave.erl index 9c74041f56..3e647635bc 100644 --- a/lib/stdlib/src/slave.erl +++ b/lib/stdlib/src/slave.erl @@ -289,7 +289,8 @@ register_unique_name(Number) -> %% If the node should run on the local host, there is %% no need to use rsh. -mk_cmd(Host, Name, Args, Waiter, Prog) -> +mk_cmd(Host, Name, Args, Waiter, Prog0) -> + Prog = quote_progname(Prog0), BasicCmd = lists:concat([Prog, " -detached -noinput -master ", node(), " ", long_or_short(), Name, "@", Host, @@ -309,6 +310,31 @@ mk_cmd(Host, Name, Args, Waiter, Prog) -> end end. +%% This is an attempt to distinguish between spaces in the program +%% path and spaces that separate arguments. The program is quoted to +%% allow spaces in the path. +%% +%% Arguments could exist either if the executable is excplicitly given +%% (through start/5) or if the -program switch to beam is used and +%% includes arguments (typically done by cerl in OTP test environment +%% in order to ensure that slave/peer nodes are started with the same +%% emulator and flags as the test node. The return from lib:progname() +%% could then typically be '/<full_path_to>/cerl -gcov'). +quote_progname(Progname) -> + do_quote_progname(string:tokens(to_list(Progname)," ")). + +do_quote_progname([Prog]) -> + "\""++Prog++"\""; +do_quote_progname([Prog,Arg|Args]) -> + case os:find_executable(Prog) of + false -> + do_quote_progname([Prog++" "++Arg | Args]); + _ -> + %% this one has an executable - we assume the rest are arguments + "\""++Prog++"\""++ + lists:flatten(lists:map(fun(X) -> [" ",X] end, [Arg|Args])) + end. + %% Give the user an opportunity to run another program, %% than the "rsh". On HP-UX rsh is called remsh; thus HP users %% must start erlang as erl -rsh remsh. |