Closed
Description
Prerequisites
- Write a descriptive title.Make sure you are able to repro it on the latest released versionSearch the existing issues.Refer to the FAQ.
Steps to reproduce
- Start PowerShell on Unix
- Press ^D
Expected behavior
mcroce@t490s:~$ pwsh
PowerShell 7.2.0
Copyright (c) Microsoft Corporation.
https://aka.ms/powershell
Type 'help' to get help.
PS /home/mcroce>
mcroce@t490s:~$
Actual behavior
mcroce@t490s:~$ pwsh
PowerShell 7.2.0
Copyright (c) Microsoft Corporation.
https://aka.ms/powershell
Type 'help' to get help.
PS /home/mcroce> mcroce@t490s:~$
Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.2.0
PSEdition Core
GitCommitId 7.2.0
OS Linux 5.15.0 #47 SMP Tue Nov 2 23:55:47 CET 2021
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Activity
jhoneill commentedon Nov 15, 2021
if you are using
you can make it
to output an empty line firest (there is no need for a space between the quotes, you can put any text 'exiting' or a an empty string, or even $null there.)
Because PSReadline is responsible for handling (and changing or acting on) commands as typed but before they are submitted it won't insert a new line, and if you type
EXIT [enter]
you already have a new line.Exit
is immediate exit and if it suffixed lines to output that would change the results of existing code which uses exit, so it would be a breaking change.As explained elsewhere #16256 ctrl-D isn't a shortcut key but the end of file marker; different OSes use different characters (ctrl Z gets you out of windows' nslookup, but ctrl D gets you out of the unix/linux version) and not all shells see input as a continuous file stream.
teknoraver commentedon Dec 8, 2021
Hi,
I never argued about ctrl-D. Ctrl-D isn't any shortcut, it's just a way to let the shell send an EOF to the process stdin.
The problem here is that no new line is print after an EOF.
The same issue exists when the shell reads an EOF, it's not related to ctrl-d at all.
Above you can see that every shell writes a new line when reaching the end of the stdin, but powershell doesn't and clobbers the prompt.
No ctrl-d involved at all this time, just regular end of stream reached.
jhoneill commentedon Dec 8, 2021
I'm not sure if the issue is actually printing the prompt when there is no more input.
You're right at best the behaviour is untidy. I thought this and the referenced query were basically the same thing, my bad on that.
teknoraver commentedon Dec 8, 2021
Well, other shells don't print the prompt if there is an EOF.
I think that this could be solved either by printing a new line, or by suppressing the last prompt.
I looked at the code, the latter is a bit more difficult.
teknoraver commentedon Aug 17, 2022
I just retried with a fresh build, and now ^D doesn't even terminates the shell.
This is the strace log:
What has been changed?
microsoft-github-policy-service commentedon Nov 15, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 22, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.