PowerShell doesn't print a new line on exit
See original GitHub issuePrerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
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
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
How do I output text without a newline in PowerShell?
The closes solution seems to use Write-Host with the -NoNewLine parameter. You can not pipe this which is a problem generally, but there...
Read more >PowerShell Code Breaks: Break Line, Not Code
The best thing is to leave out the line continuation character and simply break at the pipe, the comma, the brace, or the...
Read more >PowerShell output doesn't show until script ends
Solution: For the line that does not output, try to add " out-host"write-host "test" | out-hostAlso, maybe you want to look into the...
Read more >Force new lines in output : r/PowerShell
EDIT: I tried removing the n$line** and leaving the **$lines += $resl[$count - $i] + " n" changes in places and I get...
Read more >wt does not handle newlines properly #4619
But when I tried to run your example it turns out that the back tick does never escape the new line unless it...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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?