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

BUG: Spaces in path cause command line parser to crash #34

Open
rossbeehler opened this issue Feb 1, 2012 · 8 comments
Open

BUG: Spaces in path cause command line parser to crash #34

rossbeehler opened this issue Feb 1, 2012 · 8 comments

Comments

@rossbeehler
Copy link
Contributor

I have a command line of the following form:

"c:\Some Path With Spaces\dk.exe" execute /environment:DevFit /settings:"c:\Some Path With Spaces\settings" --silent

When I execute, I get the following error:

System.InvalidOperationException: Sequence contains more than one element
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source) at dropkick.Engine.DeploymentCommandLineParser.ExtractCommandToRun(IEnumerable1 commandLineElements)
at dropkick.Engine.DeploymentCommandLineParser.Set(DeploymentArguments arguments, IEnumerable`1 commandLineElements)
at dropkick.Engine.DeploymentCommandLineParser.Parse(String commandline)
at dropkick.Engine.Runner.Deploy(String commandLine)

This is a bug with the Magnum.CommandLineParser.MonadicCommandLineParser and underlying classes. I have issued a pull request (#6) in the phatboyg/Magnum project to fix the issue. Once that project is patched, dropkick will need to take in the new Magnum.dll.

@drusellers
Copy link
Member

Yeah this is odd but use a space instead of a : with the offending switch.

-d

On Feb 1, 2012, at 8:52 AM, [email protected] wrote:

I have a command line of the following form:

"c:\Some Path With Spaces\dk.exe" execute /environment:DevFit /settings:"c:\Some Path With Spaces\settings" --silent

When I execute, I get the following error:

System.InvalidOperationException: Sequence contains more than one element
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source) at dropkick.Engine.DeploymentCommandLineParser.ExtractCommandToRun(IEnumerable1 commandLineElements)
at dropkick.Engine.DeploymentCommandLineParser.Set(DeploymentArguments arguments, IEnumerable`1 commandLineElements)
at dropkick.Engine.DeploymentCommandLineParser.Parse(String commandline)
at dropkick.Engine.Runner.Deploy(String commandLine)

This is a bug with the Magnum.CommandLineParser.MonadicCommandLineParser and underlying classes. I have issued a pull request (#6) in the phatboyg/Magnum project to fix the issue. Once that project is patched, dropkick will need to take in the new Magnum.dll.


Reply to this email directly or view it on GitHub:
#34

@rossbeehler
Copy link
Contributor Author

I did figure that out for the switched arguments (Definitions in Magnum speak), but the exception above is actually from the full path to dk.exe (Arguments in Magnum speak). The workarounds of removing the spaces in my path or setting my working directory closer to dk.exe were more expensive than me just fixing it in Magnum.

Note that I also fixed the Definition switch to allow /switch:"some path with spaces".

@drusellers
Copy link
Member

that's what I get trying to respond at a stop light.
I will ping chris on the fix and see where that goes. thanks.
-d

On Wed, Feb 1, 2012 at 10:14 AM, rossbeehler <
[email protected]

wrote:

I did figure that out for the switched arguments (Definitions in Magnum
speak), but the exception above is actually from the full path to dk.exe
(Arguments in Magnum speak). The workarounds of removing the spaces in my
path or setting my working directory closer to dk.exe were more expensive
than me just fixing it in Magnum.

Note that I also fixed the Definition switch to allow /switch:"some path
with spaces".


Reply to this email directly or view it on GitHub:
#34 (comment)

@rossbeehler
Copy link
Contributor Author

After fixing this in Magnum, I found out that I was wrong in my assumption. It doesn't pass the path to dk.exe into the parser. What's happening is that the double quotes are getting removed from the value in /switch:"value", and that is done by .NET.

However, when I change it to have a space between the switch and value like:

/switch "value"

.NET still removes the double quotes, and thus those double quotes don't get into Magnum, and we're back to square 1.

Is there another workaround I'm missing?

@rossbeehler
Copy link
Contributor Author

I made a fix in dk.exe to add double quotes back to the .NET parsed arguments so that Magnum can properly see the double quotes. This was added to pull request #31.

@rossbeehler
Copy link
Contributor Author

I was thinking about this some more and realized that the logic to add double quotes back to the command line arguments should probably exist in Magnum and no dk.exe since System.Environment.CommandLine is globaly available . Here would be the pseudo-code in MonadicCommandLineParser:

  • foreach quotedSubstring in System.Environment.CommandLine
    • if magnumCommandLine contains quotedSubstring without double quotes around it
      • re-surround quotedSubstring with double quotes in magnumCommandLine

Let me know if that's the direction we should go, and I'll make the change in that project.

@mmooney
Copy link
Member

mmooney commented May 31, 2014

Hi @rossbeehler, where did you end up with this? I'm running into the same issue, my settings file path has spaces in it and it's blowing up the MonadicCommandLineParser. Was there a resolution or workaround for this?

Thanks

@rossbeehler
Copy link
Contributor Author

@mmooney I believe this should have been fixed with pull request #31 according to my above comment, but then I also patched it in Magnum: phatboyg/Magnum@7a170f1.

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

No branches or pull requests

3 participants