-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
Terminal doesn't honor quoted command lines. #19078
Comments
Could it be that the command line somehow get changed / corrupted until it is passed to the cmd.exe process. |
I'm guessing this is an issue with the |
Could be, but please note that I pass one arg for the command line. So instead of ["dir", "test folder"] which would need proper escaping I pass [""dir "test folder"""] which is exactly one arg and already proper escaped. |
Actually I didn't quote the command correctly. It should be quoted Executing which looks correct (no \ to escape ") |
I think I can reproduce this in node-pty by running the following: var os = require('os');
var pty = require('..');
var ptyProcess = pty.spawn('cmd.exe', ['/c', 'dir "a b"'], {
name: 'xterm-color',
cols: 80,
rows: 30,
cwd: "C:\\Users\\daimms\\Documents",
env: process.env
});
ptyProcess.on('data', function(data) {
console.log(data);
});
setTimeout(ptyProcess.kill.bind(ptyProcess), 5000); Output:
A similar example however works fine on Linux using |
Fixed upstream microsoft/node-pty#41, still want to verify it within VS Code before pushing it. |
@dbaeumer this should be good to go now, you'll want to update node_modules/node-pty and then set const config: IShellLaunchConfig = {
executable: 'cmd.exe',
args: '/d /c "dir "test folder""'
}; Let me know if you have any issues. |
@Tyriar why is the string option only supported under Windows. You need to escape under Mac and Linux as well. Under these OSes there are even three different kind of space escapings so the code can't simply take one (see http://wiki.bash-hackers.org/syntax/quoting). IMO we need to let users control this. |
@dbaeumer I was under the impression this only really applies to cmd/Windows.
From microsoft/node-pty#41 (comment) Do you have a particular use case that fails in |
@Tyriar may be I am not understanding it correctly but here is what I like to allow users do to for an example to run a command in a shell that takes args with spaces in it:
How would I pass such a command line to a shell I start under Mac / Linux? |
Aren't they all basically the same thing? Is there a reason for using anything other than |
According to http://wiki.bash-hackers.org/syntax/quoting " and ' have a very different semantic. So is there a way for me to pass args and tell the shell to not do any quoting. So if I pass |
Yes. So how would I pass this to a shellLaunchConfig in code in terms of args? Like this: ["-c", "ls -ls 'a b'"] and not one string args like under Windows ? |
Yes, |
@Tyriar thanks! |
VSCode Version: Windows.
-create a new terminal with the following shell args
![capture](https://cloud.githubusercontent.com/assets/1931590/22220218/149cfa86-e1ae-11e6-9c47-1ac8ed995532.png)
Executing this on a folder that contains a folder
test folder
results in the following error message:Using the following args (observer the additional quote around the command) results in the same error
Executing this in a command shell (cmd.exe) works:
As does on powershell (without the extra double quotes):
The text was updated successfully, but these errors were encountered: