std.process: Fix escapePosixArgumentImpl

This commit is contained in:
Vladimir Panteleev 2012-08-10 10:15:06 +03:00
parent fc99e5583e
commit 96556b54f3

View file

@ -50,7 +50,7 @@ version (Posix)
version (unittest) version (unittest)
{ {
import std.file, std.conv, std.array, std.random; import std.file, std.conv, std.array, std.random;
import std.path : rel2abs; import std.path : absolutePath;
} }
@ -990,7 +990,10 @@ private char[] escapePosixArgumentImpl(alias allocator)(in char[] arg)
buf[p++] = '\''; buf[p++] = '\'';
foreach (c; arg) foreach (c; arg)
if (c == '\'') if (c == '\'')
{
buf[p..p+4] = `'\''`; buf[p..p+4] = `'\''`;
p += 4;
}
else else
buf[p++] = c; buf[p++] = c;
buf[p++] = '\''; buf[p++] = '\'';
@ -1138,7 +1141,7 @@ unittest
// Then, test this module with: // Then, test this module with:
// rdmd --main -unittest -version=unittest_burnin process.d // rdmd --main -unittest -version=unittest_burnin process.d
auto helper = rel2abs("std_process_unittest_helper"); auto helper = absolutePath("std_process_unittest_helper");
assert(shell(helper ~ " hello").split("\0")[1..$] == ["hello"], "Helper malfunction"); assert(shell(helper ~ " hello").split("\0")[1..$] == ["hello"], "Helper malfunction");
void test(string[] s, string fn) void test(string[] s, string fn)