Skip to content

Commit

Permalink
nuke-build#1495 Not properly handling one argument with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Roadrunner67 committed Jan 1, 2025
1 parent 5b4f3ca commit b567c75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion source/Nuke.Tooling.Tests/ArgumentStringHandlerTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Maintainers of NUKE.
// Copyright 2023 Maintainers of NUKE.
// Distributed under the MIT License.
// https://github.com/nuke-build/nuke/blob/master/LICENSE

Expand Down Expand Up @@ -61,6 +61,12 @@ public void TestAbsolutePathCollection()
ArgsToString($"start {paths:sn} end").Should().Be("start C:\\foo\\bar '/foo bar/foo' end");
}

[Fact]
public void TestSpacedPathOnly()
{
ArgsToString($"{(AbsolutePath)"C:" / "Program Files"}").Should().Be("\"C:\\Program Files\"");
}

[Fact]
public void TestFormat()
{
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.Tooling/ArgumentStringHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void AppendFormatted(IEnumerable<IAbsolutePathHolder> paths, int alignmen
public string ToStringAndClear()
{
var value = _builder.ToStringAndClear();
return value.Length > 1 && value.IndexOf(value: '"', startIndex: 1) == value.Length - 1
return value.Length > 1 && value.IndexOf(value: '"', startIndex: 1) == value.Length - 1 && value.IndexOf(' ') == -1
? value.TrimMatchingDoubleQuotes()
: value;
}
Expand Down

0 comments on commit b567c75

Please sign in to comment.