Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/CommandLineUtils/Utilities/ArgumentEscaper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private static string EscapeSingleArg(string arg)
{
var sb = new StringBuilder();

var needsQuotes = ContainsWhitespace(arg);
var needsQuotes = arg.Length == 0 || ContainsWhitespace(arg);
var isQuoted = needsQuotes || IsSurroundedWithQuotes(arg);

if (needsQuotes)
Expand Down
1 change: 1 addition & 0 deletions test/CommandLineUtils.Tests/ArgumentEscaperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class ArgumentEscaperTests
[InlineData(new[] { @"C:\Program Files\dotnet\" }, @"""C:\Program Files\dotnet\\""")]
[InlineData(new[] { @"backslash\""preceedingquote" }, @"backslash\\\""preceedingquote")]
[InlineData(new[] { @""" hello nate """ }, @"""\"" hello nate \""""")]
[InlineData(new[] { "one", "", "three" }, "one \"\" three")]
public void EscapesArguments(string[] args, string expected)
{
Assert.Equal(expected, ArgumentEscaper.EscapeAndConcatenate(args));
Expand Down