{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/29669","repository_url":"https://api.github.com/repos/dotnet/corefx","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/29669/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/29669/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/29669/events","html_url":"https://github.com/dotnet/corefx/issues/29669","id":322457997,"number":29669,"title":"Control characters are being echo'ed back as user inputs ","user":{"login":"jianyunt","id":10171679,"avatar_url":"https://avatars1.githubusercontent.com/u/10171679?v=4","gravatar_id":"","url":"https://api.github.com/users/jianyunt","html_url":"https://github.com/jianyunt","followers_url":"https://api.github.com/users/jianyunt/followers","following_url":"https://api.github.com/users/jianyunt/following{/other_user}","gists_url":"https://api.github.com/users/jianyunt/gists{/gist_id}","starred_url":"https://api.github.com/users/jianyunt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jianyunt/subscriptions","organizations_url":"https://api.github.com/users/jianyunt/orgs","repos_url":"https://api.github.com/users/jianyunt/repos","events_url":"https://api.github.com/users/jianyunt/events{/privacy}","received_events_url":"https://api.github.com/users/jianyunt/received_events","type":"User","site_admin":false},"labels":[{"id":261819097,"url":"https://api.github.com/repos/dotnet/corefx/labels/area-System.Console","name":"area-System.Console","color":"d4c5f9","default":false},{"id":145399955,"url":"https://api.github.com/repos/dotnet/corefx/labels/bug","name":"bug","color":"207de5","default":true},{"id":205613977,"url":"https://api.github.com/repos/dotnet/corefx/labels/os-linux","name":"os-linux","color":"fef2c0","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/dotnet/corefx/milestones/21","html_url":"https://github.com/dotnet/corefx/milestone/21","labels_url":"https://api.github.com/repos/dotnet/corefx/milestones/21/labels","id":3242632,"number":21,"title":"2.2.0","description":"Placeholder name for next major release after 2.1. [Official release dates](https://github.com/dotnet/core/blob/master/roadmap.md) are TBD.\r\n\r\nWe will move important issues from Future to 2.2.0 as the priorities and dates for next release become more clear.","creator":{"login":"karelz","id":5776068,"avatar_url":"https://avatars2.githubusercontent.com/u/5776068?v=4","gravatar_id":"","url":"https://api.github.com/users/karelz","html_url":"https://github.com/karelz","followers_url":"https://api.github.com/users/karelz/followers","following_url":"https://api.github.com/users/karelz/following{/other_user}","gists_url":"https://api.github.com/users/karelz/gists{/gist_id}","starred_url":"https://api.github.com/users/karelz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karelz/subscriptions","organizations_url":"https://api.github.com/users/karelz/orgs","repos_url":"https://api.github.com/users/karelz/repos","events_url":"https://api.github.com/users/karelz/events{/privacy}","received_events_url":"https://api.github.com/users/karelz/received_events","type":"User","site_admin":false},"open_issues":141,"closed_issues":445,"state":"open","created_at":"2018-04-04T16:40:10Z","updated_at":"2018-05-14T16:21:24Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2018-05-11T23:06:07Z","updated_at":"2018-05-14T17:02:13Z","closed_at":null,"author_association":"NONE","body":"Background\r\n------------\r\nIn PowerShell Core (pwsh) on `Linux` or Azure Cloudshell (bash-Linux), when doing demos, we are consistently getting `OC`, `OD` characters magically inserted as a part of user inputs while pressing LeftArrow or RightArrow keys.  The situation occurs even more often when the PowerShell cmdlets display verbose messages or output messages, or running background jobs.\r\n\r\nSample\r\n-------\r\n ``` C#\r\n  //mimicking PowerShell executes a cmdlet\r\n   Console.TreatControlCAsInput = true;\r\n   var i = 100;\r\n   while (i-- > 0)\r\n   {\r\n\tThread.Sleep (50);\r\n\tConsole.WriteLine (\"Working on it ...\");\r\n   }\r\n  \r\n   //PowerShell sets the cursor to begining after done with the execution\r\n    var left = Console.CursorLeft;\r\n    var top = Console.CursorTop;\r\n    Console.WriteLine (\"Left={0}, Top={1}\", left, top);\r\n\r\n    \r\n    ConsoleKeyInfo input;\r\n    do {\r\n        input = Console.ReadKey(true);\r\n         Console.WriteLine(\"{0}\", input.Key);\r\n    } while (input.Key.ToString() != \"Q\");\r\n\r\n\r\n```\r\n  \r\nSample Output\r\n------\r\nPress leftarrow key when you see \"Working on it\" message and then Q to quit. You will \"O\" and \"D\" instead of LeftArrow key.\r\n![image](https://user-images.githubusercontent.com/10171679/39949895-b10bce30-5532-11e8-8190-e8ce84dffe4b.png)\r\n\r\n\r\n\r\n\r\nRepro through PowerShell\r\n-------------------\r\n1. Linux VM\r\n2. Install the PowerShell core from https://github.com/PowerShell/powershell#get-powershell\r\n\r\nor https://portal.azure.com/\r\n\r\n3. pwsh\r\n4. We use the following script for doing something like background auth:\r\n         $timer = New-Object Timers.Timer\r\n         $timer.Interval=500\r\n         $timer.Enabled=$true\r\n         foreach ($a in 1..5){Register-ObjectEvent -InputObject $timer -EventName Elapsed -SourceIdentifier $a -Action {Start-Sleep -milliseconds 100}\r\n\r\n\r\n5. Type any cmdlet e.g., Get-Module cmdlet  \r\n6. Press Left or Right arrow\r\n7. You may see\r\n![image](https://user-images.githubusercontent.com/10171679/39949568-59828ebc-5530-11e8-9dfe-e8f85e6f73d4.png)\r\n\r\n\r\nInitial Investigation\r\n------------\r\nWhen PowerShell completes a cmdlet execution, it sets the cursor to beginning by calling Console.CursorLeft and Console.CursorTop which in turn calls into  GetCursorPosition()  https://github.com/dotnet/corefx/blob/master/src/System.Console/src/System/ConsolePal.Unix.cs#L372.\r\nBecause GetCursorPostion() stripped out the ESC  (^[OD) for example, but put OD into the  _unprocessdBufferToBeRead buffer, so next time when Console.ReadKey() gets called, we are getting OD instead of the multiple character terminal sequence.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/dotnet/corefx/issues/comments/388889938","html_url":"https://github.com/dotnet/corefx/issues/29669#issuecomment-388889938","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/29669","id":388889938,"user":{"login":"jianyunt","id":10171679,"avatar_url":"https://avatars1.githubusercontent.com/u/10171679?v=4","gravatar_id":"","url":"https://api.github.com/users/jianyunt","html_url":"https://github.com/jianyunt","followers_url":"https://api.github.com/users/jianyunt/followers","following_url":"https://api.github.com/users/jianyunt/following{/other_user}","gists_url":"https://api.github.com/users/jianyunt/gists{/gist_id}","starred_url":"https://api.github.com/users/jianyunt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jianyunt/subscriptions","organizations_url":"https://api.github.com/users/jianyunt/orgs","repos_url":"https://api.github.com/users/jianyunt/repos","events_url":"https://api.github.com/users/jianyunt/events{/privacy}","received_events_url":"https://api.github.com/users/jianyunt/received_events","type":"User","site_admin":false},"created_at":"2018-05-14T17:02:12Z","updated_at":"2018-05-14T17:02:12Z","author_association":"NONE","body":"@karelz, yes it's happening in the latest release. Echo'ing control keys back in linux terminal  ^[OC, may not such big problem for us, for example, bash does the similar. However losing ESC and echoing back with consolekey code like OC, OD etc. as user inputs is the problem. Currently this issue is considered as blocking for `PowerShell Azure CloudShell` GA. Please take priority for the fix. Thanks.\r\nCC @SteveL-MSFT, @edyoung  @HemantMahawar"}}
{"actor":{"display_login":"jianyunt"}}