diff options
author | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2011-09-15 18:39:14 +0200 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2011-09-15 18:39:14 +0200 |
commit | fa1bbc67027b3382ccfe5efc791e8105c52c1d64 (patch) | |
tree | b3377168d093e0d99c96d1e5bdf350f664b53528 | |
parent | 317eeb72e0e4a6855910a7ac26295735ccb77553 (diff) |
Fix regressions in rebar_file_utils
-rw-r--r-- | src/rebar_file_utils.erl | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl index d026395..708ab42 100644 --- a/src/rebar_file_utils.erl +++ b/src/rebar_file_utils.erl @@ -43,8 +43,7 @@ rm_rf(Target) -> case os:type() of {unix, _} -> - EscTarget = re:replace(Target, " ", "\\\\ ", - [global, {return, list}]), + EscTarget = escape_spaces(Target), {ok, []} = rebar_utils:sh(?FMT("rm -rf ~s", [EscTarget]), [{use_stdout, false}, return_on_error]), ok; @@ -61,8 +60,8 @@ rm_rf(Target) -> cp_r(Sources, Dest) -> case os:type() of {unix, _} -> - QuotedSources = ["\"" ++ Src ++ "\"" || Src <- Sources], - SourceStr = string:join(QuotedSources, " "), + EscSources = [escape_spaces(Src) || Src <- Sources], + SourceStr = string:join(EscSources, " "), {ok, []} = rebar_utils:sh(?FMT("cp -R ~s \"~s\"", [SourceStr, Dest]), [{use_stdout, false}, return_on_error]), @@ -76,7 +75,9 @@ cp_r(Sources, Dest) -> mv(Source, Dest) -> case os:type() of {unix, _} -> - {ok, []} = rebar_utils:sh(?FMT("mv \"~s\" \"~s\"", [Source, Dest]), + EscSource = escape_spaces(Source), + EscDest = escape_spaces(Dest), + {ok, []} = rebar_utils:sh(?FMT("mv ~s ~s", [EscSource, EscDest]), [{use_stdout, false}, return_on_error]), ok; {win32, _} -> @@ -155,3 +156,6 @@ cp_r_win32(Source,Dest) -> ok = cp_r_win32({filelib:is_dir(Src), Src}, Dst) end, filelib:wildcard(Source)), ok. + +escape_spaces(Str) -> + re:replace(Str, " ", "\\\\ ", [global, {return, list}]). |