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

Windows doesn't support spaces in arguments #8

Open
emersion opened this issue Aug 21, 2017 · 11 comments
Open

Windows doesn't support spaces in arguments #8

emersion opened this issue Aug 21, 2017 · 11 comments
Labels

Comments

@emersion
Copy link
Owner

No description provided.

@Aelphy
Copy link
Contributor

Aelphy commented Aug 21, 2017

Qute is also a bad idea because it produces exploding amount of escaped quotes

@emersion
Copy link
Owner Author

Well, at least quoting works, just putting spaces doesn't. win32's SetArguments only accepts strings, so there aren't a lot of solutions.

@Aelphy
Copy link
Contributor

Aelphy commented Aug 21, 2017

quoting doesn't work, we have tested it with single argument on windows 10

@emersion
Copy link
Owner Author

My bad, I though it worked. That's strange, maybe only quoting arguments that contain a space can solve this issue?

@Aelphy
Copy link
Contributor

Aelphy commented Aug 21, 2017

Yah, that should work.
I will test it and pull request if it helps

@cuthix
Copy link
Contributor

cuthix commented Sep 20, 2017

There is no need to quote the arguments. I tested windows 7,10 and both are accepting arguments with spaces. Only the path to executable should be quoted if contain spaces and this is already treated properly.

@emersion
Copy link
Owner Author

I don't think so. args is a string of space-separated arguments.

@cuthix
Copy link
Contributor

cuthix commented Sep 20, 2017

yes, but the windows will send all arguments to go program and urfave/cli will handle this

e.g. --log-level=debug works as well as --log-level debug

@emersion
Copy link
Owner Author

When I talk about spaces in arguments, I talk about something like --display-name="Mitsuha Miyamizu". I don't want this to become two arguments (--display-name="Mitsuha and Miyamizu"). This looks like this when calling the library:

args := []string{"--log-level", "debug", "--display-name", "Mitsuha Miyamizu"}

@cuthix
Copy link
Contributor

cuthix commented Sep 20, 2017

I think the arguments should be used like this

args := []string{"--log-level", "debug", "--display-name", "\"Mitsuha Miyamizu\""}

and the users should think about this.

@emersion
Copy link
Owner Author

emersion commented Sep 20, 2017

and the users should think about this

Nope, for two reasons. First, arguments in a []string are expected by users to be escaped properly, because it's done like this in the standard library. This is also a safeguard against security issues if library users forget this edge case (arguments could be strings entered by the app user).

Also, the macOS actually uses a config file like this:

<argument>--log-level</argument>
<argument>debug</argument>
<argument>--display-name</argument>
<argument>"Mitsuha Miyamizu"</argument>

And the program will be spawned with --log-level debug --display-name "\"Mitsuha Miyamizu\"" (so the last argument value becomes "Mitsuha Miyamizu" instead of Mitsuha Miyamizu).

@emersion emersion added the bug label Sep 21, 2017
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

3 participants