aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2013-06-05 14:52:22 +0200
committerSiri Hansen <[email protected]>2013-06-05 14:52:22 +0200
commit23623a4837f3971623549c73257474d828fe25f2 (patch)
tree40ddd5b6c10184db79a2010ae9a4fd5b68eda32f /lib/stdlib
parentaf03cbc7b14fc504e181332d6902de109049725f (diff)
parentdd850c00803939e44d7f2ea6659825d0ab861b9d (diff)
downloadotp-23623a4837f3971623549c73257474d828fe25f2.tar.gz
otp-23623a4837f3971623549c73257474d828fe25f2.tar.bz2
otp-23623a4837f3971623549c73257474d828fe25f2.zip
Merge branch 'siri/spawn-and-space'
* siri/spawn-and-space: [sasl] In test, quote erlsrv executable in call to open_port/2 [test_server] Quote path to erl executable when starting slave nodes Quote path to erl executable in slave to allow space in path [sasl] Quote path to program run with open_port({spawn,... [os_mon] Quote path to programs run with open_port({spawn,... Conflicts: lib/os_mon/src/nteventlog.erl
Diffstat (limited to 'lib/stdlib')
-rw-r--r--lib/stdlib/src/slave.erl28
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.