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

No good way to pass arguments which contain whitespace or special characters to scripts #5999

Closed
fernsehkind opened this issue Dec 27, 2018 · 7 comments · Fixed by #6004
Closed
Milestone

Comments

@fernsehkind
Copy link
Contributor

fernsehkind commented Dec 27, 2018

Do you want to request a feature or report a bug?

Bug and Feature

What is the current behavior?

  • Settings/Scripts

  • Example argument: c:\foo.py -c {WorkingDir} -h {hash}, WorkingDir is set to c:\temp path with spaces\

  • Is expanded to c:\foo.py -c c:\temp path with spaces\ -hash xyz. The foo.py script does not recognize the path correctly because it detects it as multiple arguments

  • Other example argument: c:\foo.py -c "{WorkingDir}" -h "{hash}", WorkingDir is set to c:\temp path with spaces\

  • Is expanded to c:\foo.py -c "c:\temp path with spaces\" -hash xyz. The foo.py script does not recognize the path correctly because the backspace at the end escapes the quote character

Environment you encounter the issue:

  • GitExtensions version: 3.01.00.0
  • GIT version: 2.20.1.windows.1
  • OS version: Win 10 Pro (10.0.17763.0)
  • .NET version: 4.7.3260.0

Did this work in previous version of GitExtensions (which)?

No

@vbjay
Copy link
Contributor

vbjay commented Dec 27, 2018 via email

@fernsehkind
Copy link
Contributor Author

Does not work for {WorkingDir} because the ' is also escaped. I pushed a possible solution for this. Please have a look.

@vbjay
Copy link
Contributor

vbjay commented Dec 27, 2018

Create a branch for that commit and push it to your repo. Then create a pull request against your branch to our master. In the fixes line of the pull request put 5999 after the #. You can rebase the commit so it doesn't have the fix gitextensions... piece. The pull request will handle the closing of the issue.

@vbjay
Copy link
Contributor

vbjay commented Dec 27, 2018

@vbjay
Copy link
Contributor

vbjay commented Dec 27, 2018

Thanks for testing the ' too. FYI expect a review on that commit when you create the pull request.

@RussKie
Copy link
Member

RussKie commented Dec 28, 2018

I think this is an ancient bug in MS .NET CLI parser, we've dealt with it before: #3489 (comment)

  • Is expanded to c:\foo.py -c "c:\temp path with spaces\" -hash xyz. The foo.py script does not recognize the path correctly because the backspace at the end escapes the quote character

I believe it should work if you add a space before the closing quote, like so
c:\foo.py -c "{WorkingDir} " -h "{hash}".
Please try it.

@fernsehkind
Copy link
Contributor Author

This workaround may work in several cases but:

  1. A space at the end of working dir is added which may not be acceptable for all kind of scripts which are called
  2. When a double quote is contained in the argument (e.g. Commit message) it is also not possible to use the script function correctly because they are not escaped. See also 6db9703

RussKie added a commit that referenced this issue Jan 7, 2019
Fix #5999: Add option to quote arguments in script parser
@RussKie RussKie added this to the 3.1.0 milestone Jan 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants