FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Make ConsoleHost honor NoEcho on Unix platforms by JamesWTruher · Pull Request #3801 · PowerShell/PowerShell · GitHub

Make ConsoleHost honor NoEcho on Unix platforms - #3801

Merged
Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
JamesWTruher:jameswtruher/ReadKeyNoEcho
Jun 9, 2017
Merged

Make ConsoleHost honor NoEcho on Unix platforms#3801
Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
JamesWTruher:jameswtruher/ReadKeyNoEcho

Conversation

James Truher (JamesWTruher) commented May 17, 2017
edited by daxian-dbw
Loading

Copy link
Copy Markdown
Collaborator

Fix #3183
this also affects Linux as well.

This does not provide support for IncludeKeyDown or IncludeKeyUp, but does not
echo the character when provided. In order to support IncludeKeyDown and IncludeKeyUp a
more substantial rewrite will be needed as Console.ReadKey doesn't support this behavior.

Copy link
Copy Markdown
Collaborator Author

I should add that I haven't been able to figure out a way to actually test this other than manually. I investigated how the corefx guys test Console.ReadKey, and they do it manually. That is, their automation calls a test which then requires that a user type keys which are then validated by the user.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

key = Console.ReadKey(options.HasFlag(NoEcho))?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

fixed

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Actually, we should avoid HasFlag, because it's much, much more expensive than a simple bitwise test. HasFlag calls into a native implementation -- see the implementation here: https://github.com/dotnet/coreclr/blob/e67851210d1c03d730a3bc97a87e8a6713bbf772/src/vm/reflectioninvocation.cpp#L3699

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Could you please remove the extra empty line?

Dongbo Wang (daxian-dbw) changed the title fix for issue #3183, honor NoEcho on OSX Make ConsoleHost honor NoEcho on Unix platforms May 24, 2017

Copy link
Copy Markdown
Member

Title updated -- it's recommended to briefly describe what is fixed in the PR title, and put "Fix #" in the PR's body. See the contribution.md at https://github.com/PowerShell/PowerShell/blob/master/.github/CONTRIBUTING.md#pull-request-submission

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please avoid the use of the HasFlag api - it is much, much slower than the simple bit test - see the implementation here. The expensive part is mostly boxing, but you can see it does other work before the simple bitwise test.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

it would be better to get uniform input - one person's opinion vs another. My original code was requested to change to this

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Sorry, I don't see that feedback, so I can't comment on that.

It's not an opinion that the api is significantly slower, e.g. see here - that's the second hit for me on this search

My preference is to avoid the api completely because:

  1. We do have places where the api would make PowerShell measurably slower
  2. People working in our code base should be comfortable reading and writing code that is equivalent to this api
  3. People tend to copy the style, so avoiding the api helps avoid usage creeping into places that matter.

Again, this is just feedback - I'm not blocking the PR.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

i agree completely, there's even an open issue in corefx (https://github.com/dotnet/corefx/issues/15453). My original code did not use hasflag, which I will put back.

This does not provide support for IncludeKeyDown or IncludeKeyUp, but does not
echo the character when provided. In order to support IncludeKeyDown and IncludeKeyUp a
more substantial rewrite will be needed as Console.ReadKey doesn't support this behavior.
This applies to both OSX and Linux.

Copy link
Copy Markdown
Collaborator Author

I think all the feedback has been addressed Dongbo Wang (@daxian-dbw) ?

Dongbo Wang (daxian-dbw) merged commit 759aff1 into PowerShell:master Jun 9, 2017
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

6 participants


Back | FazBrowse Home | New Git URL