Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentStringHandler bug #1495

Open
Roadrunner67 opened this issue Dec 17, 2024 · 1 comment
Open

ArgumentStringHandler bug #1495

Roadrunner67 opened this issue Dec 17, 2024 · 1 comment
Labels

Comments

@Roadrunner67
Copy link
Contributor

Roadrunner67 commented Dec 17, 2024

Usage Information

9.0.3 / 8.0.11 / net8 / Windows 11

Description

If you declare a tool that takes a directory as its only argument and that directory contains spaces, ArgumentStringHandler will not quote the path.

Reproduction Steps

Add this test to ArgumentStringHandlerTest:

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

Expected Behavior

string path = "C:/Program Files";
MyTool($"{path}");
should call:
path_to_tool/MyTool.exe "C:/Program Files"

Actual Behavior

no quotes:
path_to_tool/MyTool.exe C:/Program Files

Regression?

7.0.2 on net6 did not do this

Known Workarounds

Adding a space at the end seems to help:
MyTool($"{path} ");

Could you help with a pull-request?

Yes

@Roadrunner67
Copy link
Contributor Author

This is the works of ArgumentStringHandler.ToStringAndClear() which basically concludes: If there are only quotes at the start and at the end, then they can be safely removed, which is rubbish if there is a space in between.

I have posted PR #1501 to fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant