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

Fix Windows installation when username has space in it #634

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

chaos95
Copy link
Contributor

@chaos95 chaos95 commented Oct 26, 2022

This change modifies run_unzip.cmd and run_gzip.cmd to wrap invocations and paths in quotes.

This prevents issues arising where a user's home directory has spaces in it due to their username, such as 'C:\Users\FirstName LastName', which causes commands to fail because they parse the different parts of the path as separate arguments.

This change is not a complete solution - there are still quite a few individual installer scripts that make use of %~dp0 without quotes, but these central changes to unzip and gzip should solve the problem for at least a few people. I would be happy to submit future PRs for the individual installers as time permits.

- Modify run_unzip.cmd to wrap invocations and paths in quotes
  - This prevents issues where a user's home directory has spaces in it due to their username, such as 'C:\Users\FirstName LastName', from causing commands to fail because they parse the different parts of the path as separate arguments.
- This change applies the same fix to run_gzip.cmd as the previous
  commit.
@mattn
Copy link
Owner

mattn commented Oct 26, 2022

I suspect that this modification will make it even worse.

Current implementation:

test.c

#include <stdio.h>

int
main(int argc, char* argv[]) {
  int i = 0;
  for (i = 0; i < argc; i++) {
    puts(argv[i]);
  }
  return 0;
}

test.bat

@echo off
.\test.exe %*
C:\test>test.bat "foo bar"
foo bar

And with change

test.bat

@echo off
.\test.exe "%*"
C:\test>test.bat "foo bar"
foo
bar

@chaos95
Copy link
Contributor Author

chaos95 commented Oct 31, 2022

True. I think it might be sufficient to wrap the commands in quotes and leave the arguments unquoted. For all of the invocations of unzip.cmd that I can see, the arguments are relative paths, so there are no spaces in them. But because the path to unzip.cmd itself might contain spaces, that still needs to be quoted. I'll update the PR shortly :)

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

Successfully merging this pull request may close these issues.

None yet

2 participants