Skip to content

fix(exec): now actually supports shell option#348

Merged
nfischer merged 1 commit intomasterfrom
test-exec-shell-option
Feb 14, 2016
Merged

fix(exec): now actually supports shell option#348
nfischer merged 1 commit intomasterfrom
test-exec-shell-option

Conversation

@nfischer
Copy link
Copy Markdown
Member

@nfischer nfischer commented Feb 9, 2016

Looks like #335 doesn't work perfectly with all options. This is because execSync does 2 calls to exec(), and some options need to be passed to both calls.

This should clean things up a bit, and fix the issue for the shell option, which would actually fix #138 and #208.

@nfischer nfischer mentioned this pull request Feb 9, 2016
@nfischer nfischer added this to the v0.7.0 milestone Feb 9, 2016
@nfischer nfischer added the fix Bug/defect, or a fix for such a problem label Feb 9, 2016
src/exec.js Outdated
var execCommand = '"'+process.execPath+'" '+scriptFile;
var script;

var optArray = [];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this should just be an object that we JSON.stringify.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would probably be better. I'll look into that.

@nfischer
Copy link
Copy Markdown
Member Author

@ariporad This should be good now

@nfischer nfischer force-pushed the test-exec-shell-option branch from e853caa to 358e3ff Compare February 11, 2016 20:52
test/exec.js Outdated
// check process.env works
assert.ok(!shell.env.FOO);
shell.env.FOO = 'Hello world';
result = shell.exec('echo $FOO');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd.exe doesn't support variables prefixed with a $, what you want here is %FOO%.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Good catch

@ariporad
Copy link
Copy Markdown
Contributor

LGTM, except for AppVeyor, which is failing.

@nfischer nfischer force-pushed the test-exec-shell-option branch from 358e3ff to b63dde5 Compare February 14, 2016 04:45
@nfischer
Copy link
Copy Markdown
Member Author

@ariporad it should be working now

nfischer added a commit that referenced this pull request Feb 14, 2016
fix(exec): now actually supports shell option
@nfischer nfischer merged commit 3cd360c into master Feb 14, 2016
var script;

opts.cwd = path.resolve(opts.cwd);
var optString = JSON.stringify(opts);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't safe against Unicode newlines (namely, U+2028 and U+2029): http://stackoverflow.com/a/9168133/1937836

Something like https://www.npmjs.com/package/js-stringify should fix this issue

@nfischer nfischer deleted the test-exec-shell-option branch February 16, 2016 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug/defect, or a fix for such a problem medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shell builtin

3 participants