go-autostart icon indicating copy to clipboard operation
go-autostart copied to clipboard

Windows doesn't support spaces in arguments

Open emersion opened this issue 8 years ago • 11 comments

emersion avatar Aug 21 '17 15:08 emersion

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

Aelphy avatar Aug 21 '17 15:08 Aelphy

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

emersion avatar Aug 21 '17 15:08 emersion

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

Aelphy avatar Aug 21 '17 15:08 Aelphy

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

emersion avatar Aug 21 '17 15:08 emersion

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

Aelphy avatar Aug 21 '17 16:08 Aelphy

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.

cuthix avatar Sep 20 '17 13:09 cuthix

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

emersion avatar Sep 20 '17 13:09 emersion

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

cuthix avatar Sep 20 '17 13:09 cuthix

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"}

emersion avatar Sep 20 '17 13:09 emersion

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.

cuthix avatar Sep 20 '17 13:09 cuthix

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 avatar Sep 20 '17 13:09 emersion