Skip to content

Require to use "-" when reading from stdin#40424

Merged
bpasero merged 4 commits intorelease/1.19from
ben/40351
Dec 18, 2017
Merged

Require to use "-" when reading from stdin#40424
bpasero merged 4 commits intorelease/1.19from
ben/40351

Conversation

@bpasero
Copy link
Copy Markdown
Member

@bpasero bpasero commented Dec 18, 2017

fixes #40351

@bpasero bpasero added the candidate Issue identified as probable candidate for fixing in the next release label Dec 18, 2017
@bpasero bpasero self-assigned this Dec 18, 2017
@bpasero bpasero requested a review from joaomoreno December 18, 2017 09:36
@bpasero bpasero added this to the November Recovery 2017 milestone Dec 18, 2017
Comment thread src/vs/code/node/cli.ts Outdated
}, 1000);

// ...but finish early if we detect data
process.stdin.on('data', () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this be once instead of on?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, should the listener be detached when this promise resolves?

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.

@joaomoreno good point, fixed via aa8895a

}

export const optionsHelp: { [name: string]: string; } = {
'-': isWindows ? localize('stdinWindows', "Read output from another program (e.g. 'echo Hello World | {0} -').", product.applicationName) : localize('stdinUnix', "Read from stdin (e.g. 'ps aux | grep code | {0} -').", product.applicationName),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

- isn't an option, I wouldn't put it here since options can be put in any position of the CLI. - seems to be only placeable where files are. I would either omit this advanced option in the help message, or simply document it further down: instead of a file path you can also use - to read input from stdin. Something like that.

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.

@joaomoreno good point, please check dfbff7f

Comment thread src/vs/code/node/cli.ts Outdated
argv.push('--skip-add-to-recently-opened');
args.wait = true;
} catch (error) {
stdinFileError = error;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The only code which will throw is on line 105: const stdinFileStream.... Should that line be the only one wrapped in a try catch block?

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.

@joaomoreno fixed via 7dbdccb

Comment thread src/vs/code/node/cli.ts Outdated
let stdinFileError: Error;
try {
const stdinFileStream = fs.createWriteStream(stdinFilePath);
resolveTerminalEncoding(verbose).done(encoding => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What happens in this promise's error case?

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.

@joaomoreno actually resolveTerminalEncoding is never returning with an error

Copy link
Copy Markdown
Member

@joaomoreno joaomoreno left a comment

Choose a reason for hiding this comment

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

LGTM

@bpasero bpasero merged commit 3b194af into release/1.19 Dec 18, 2017
@bpasero bpasero deleted the ben/40351 branch December 18, 2017 13:20
bpasero added a commit that referenced this pull request Dec 18, 2017
* Require to use "-" when reading from stdin

* cli - better help message

* more narrow error handling

* better data listener
@bpasero bpasero removed this from the November Recovery 2017 milestone Dec 19, 2017
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

candidate Issue identified as probable candidate for fixing in the next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants