diff options
author | Tristan Sloughter <t@crashfast.com> | 2014-11-27 08:33:01 -0600 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2014-11-27 08:34:03 -0600 |
commit | 154b70b46633287e3a61fb81ec3d638f2ddb42eb (patch) | |
tree | a847f7a7e989f22310921c12d0740dca3d5af08f | |
parent | 572b2f5ecb7abcc19b3ace962224e7040831c118 (diff) |
properly escape paths
-rw-r--r-- | src/rebar_file_utils.erl | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl index 9ddbf27..0fc1403 100644 --- a/src/rebar_file_utils.erl +++ b/src/rebar_file_utils.erl @@ -44,7 +44,7 @@ rm_rf(Target) -> case os:type() of {unix, _} -> - EscTarget = escape_spaces(Target), + EscTarget = escape_path(Target), {ok, []} = rebar_utils:sh(?FMT("rm -rf ~s", [EscTarget]), [{use_stdout, false}, abort_on_error]), ok; @@ -63,7 +63,7 @@ cp_r([], _Dest) -> cp_r(Sources, Dest) -> case os:type() of {unix, _} -> - EscSources = [escape_spaces(Src) || Src <- Sources], + EscSources = [escape_path(Src) || Src <- Sources], SourceStr = string:join(EscSources, " "), {ok, []} = rebar_utils:sh(?FMT("cp -R ~s \"~s\"", [SourceStr, Dest]), @@ -78,8 +78,8 @@ cp_r(Sources, Dest) -> mv(Source, Dest) -> case os:type() of {unix, _} -> - EscSource = escape_spaces(Source), - EscDest = escape_spaces(Dest), + EscSource = escape_path(Source), + EscDest = escape_path(Dest), {ok, []} = rebar_utils:sh(?FMT("mv ~s ~s", [EscSource, EscDest]), [{use_stdout, false}, abort_on_error]), ok; @@ -190,5 +190,5 @@ cp_r_win32(Source,Dest) -> end, filelib:wildcard(Source)), ok. -escape_spaces(Str) -> - re:replace(Str, " ", "\\\\ ", [global, {return, list}]). +escape_path(Str) -> + re:replace(Str, "([ ()?])", "\\\\&", [global, {return, list}]). |