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

Task running a quoted .cmd file name fails #40995

Closed
robinmattern opened this issue Dec 31, 2017 · 4 comments
Closed

Task running a quoted .cmd file name fails #40995

robinmattern opened this issue Dec 31, 2017 · 4 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) tasks Task system issues

Comments

@robinmattern
Copy link

If a Windows .cmd file name is included in quotes, why is the task failing on a parse error??

Steps to Reproduce:

  1. Create a shell task with a ")" in the command file name
 { "label"         : "Test Paren in File Name",   
   "type"          : "shell",
   "command"       : "\"sc71231)_Test.cmd\"",
   "presentation"  : { "echo": true }
 },
  1. Run it
> Executing task: "sc71231)_Test.cmd" <

At line:1 char:8
+ sc71231)_Test.cmd
+        ~
Unexpected token ')' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

The terminal process terminated with exit code: 1
  • VSCode Version: Code 1.19.1 (0759f77, 2017-12-19T09:46:23.884Z)
  • OS Version: Windows_NT x64 10.0.15063
  • Extensions:
Extension Author (truncated) Version
printcode nob 1.0.4
vscode-docker Pet 0.0.22
html-preview-vscode tht 0.1.1

Reproduces without extensions: Yes/No

@vscodebot vscodebot bot added the tasks Task system issues label Dec 31, 2017
@robinmattern
Copy link
Author

This issue is the same as this one: " doesn't work correctly in tasks.json #31722

Basically anytime "" ... "" is used in a shell task command, if there is a space or invalid character in the path or file name, the task fails. In particular, this ""${file}"" fails for the same reason.

@dbaeumer
Copy link
Member

dbaeumer commented Jan 8, 2018

There is more to is than the ". In PowerShell ) has a special meaning when pass on the command line. Have you tried to put this in single quotes. E.g. 'sc71231)_Test.cmd' ?

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Jan 8, 2018
@robinmattern
Copy link
Author

Thanks for the reply. I understand the ')' is problematic, but I just that any filename inside double quotes should be ignored.

  • I can't put "command": 'A file' in the tasks.json file as it is not legal JSON
  • Doing this "command": "'A file'" just prints out the file name
  • If I try to pass the file name to CMD, I get this error due to the space in the file name
    image
  • What I really want to do is execute the current file being edited with the associated program for the file's extension, as follows:
    image

@dbaeumer
Copy link
Member

This got fixed via #45576. You can now have a comment

{
   "value": "sc71231)_Test.cmd",
   "qouting": "strong"
}

which will do a strong quoting of the command to execute on all know shells (PowerShell, cmd, ...).

@dbaeumer dbaeumer added *duplicate Issue identified as a duplicate of another issue(s) and removed info-needed Issue requires more information from poster labels Mar 12, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) tasks Task system issues
Projects
None yet
Development

No branches or pull requests

2 participants