8000 Have eval read code from "stdin" when code argument is absent by atifaziz · Pull Request #547 · dotnet-script/dotnet-script · GitHub
[go: up one dir, main page]

Skip to content

Have eval read code from "stdin" when code argument is absent #547

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

Merged
merged 5 commits into from
Jun 26, 2020

Conversation

atifaziz
Copy link
Contributor
@atifaziz atifaziz commented Jun 5, 2020

This is a PR for #546, and while I understand that the idea proposed hasn't been blessed/approved, I thought I'd nonetheless share a PR to demonstrate the minimum changes needed and in case anyone wants to take it for a test drive.

c.ShowHelp();
return 0;
}
var source = string.IsNullOrWhiteSpace(code.Value) ? await Console.In.ReadToEndAsync() : code.Value;
Copy link
Member

Choose a reason for hiding this comment

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

this is a nice idea, but what if the piped input is not there? it just hangs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, just like cat and many other tools that default to receiving content over standard input. That said, I can imagine it being confusing for many. Having the ability to interactively type the input isn't going to be the common case and the experience varies sufficiently (e.g. line editing & EOF) between terminals and platforms that it will only add to the confusion. I have therefore made an update with ee28276 where Console.IsInputRedirected is used to detect if standard input has been redirected and display help otherwise. So now, we are back to the current behaviour where dotnet script eval alone will display help, but if there's code provided as an argument or supplied over standard input, then it's executed.

Copy link
Member
@filipw filipw left a comment

Choose a reason for hiding this comment

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

thanks!

@filipw filipw merged commit 7a798a5 into dotnet-script:master Jun 26, 2020
@atifaziz atifaziz deleted the eval-stdin branch June 26, 2020 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0