Here is what I get with zsh-5.4.2:
root@nixos> echo -n "abc\ndef"
abc
It's very confusing, if a program outputs a single unterminated error message and then exits.
With zsh-5.3.1, everything is fine:
root@nixos> echo -n "abc\ndef"
abc
def%
Install zsh in nixos, run zsh, execute a command that outputs an unterminated line.
I can reproduce it
I can reproduce. Could this possibly be a zsh issue?
Most probably it is. Or it can be a problem of the prompt (I don't think Nixos uses the default zsh prompt).
5.4.2 from Nixpkgs, non-NixOS prompt, works fine/could not reproduce issue.
edit: ignore the following, it's just because the default prompt is on a single line
Wait, it might be our zshrc?
I exaplain:
zsh prompt: run zsh (uses zshrc) -> echo -n "hi" -> nothing
zsh prompt: run zsh -f -d ( no zshrc) -> echo -n "hi" -> hi%
Yes, I can reproduce it here, too.
Another strange thing:
$> echo -n"abc\ndef"
-nabc
def
$> echo "abc\ndef"
abc
def
$> echo -E "abc\ndef"
abc\ndef
Maybe things of echo builtin?
Maybe things of echo builtin?
No. I originally encountered it with my own Perl program.
bash: echo = "\n\n"
bash: echo -n = "\n"
zsh: echo = "\n"
zsh: echo -n ""
Yeah it's eating the last newline
@7c6f434c can you test if you get this output?

/nix/store/<hash>-coreutils-8.28/bin/echo -e '1\n1'
1
1
/nix/store/<hash>-coreutils-8.28/bin/echo -ne '1\n11\n111\n1111\na'
1
11
111
1111
And in fish it runs OK!
@AndersonTorres it does not depend on echo. both builtin and coretuils echo have the same (wrong) output on zsh and the same (right) output on bash
@nico202 technically, I get colour-inverted version of same, but yes, that's how I have tested the issue in the first place and that's what I get.
For reference, I am not using the default NixOS prompt.
With zsh -d -f for me it works:
nixos% echo -n "abc\ndef"
abc
def%
nixos%
@nico202 not sure if this is expected?
More investigation needed but after stumbling on this:
https://www.bountysource.com/issues/48757141-failure-to-output-content-without-newline
I added setopt prompt_sp to my ~/.zshrc (well I added it to the list) and this seems to work now.
Inclined to say "working as expected" but I'm not sure if there are things to patch up re:themes and such.
It's an upstream problem. They changed interaction of the prompt_sp option with prompt_opts (https://github.com/zsh-users/zsh/commit/43e55a9bcd2c90124a751f2597d2f33cb6e3c042), but forgot to update the built-in prompts - at least, the "walters" prompt that Nixos uses by default.
Is this resolved now?
Well the behavior is still present, but since it's an upstream problem and one everyone has (AFAIK?) I think we can go ahead and close this.
Not sure it can be closed like this. For upstream, this is a problem with one of their many prompts, but for Nixos, it's a problem that occurs in default configuration.
Thanks for speaking up and clarifying. Reopening, sorry :).
I hit this issue, too. It took a lot of my time understanding that zsh's configuration was the problem, not my program.
autoload -U promptinit && promptinit && prompt walters
the last 'promp walters' is causing it.
It could be fixed by setopt prompt_sp
If you added this to promptInit after walter I think people (me ?) would be happy :)
Done in #66992
@LnL7 looks like this should also be updated on darwin-nix, actually if one uses oh-my-zsh with themes like agnoster, setting promptInit to empty is better, otherwise one can see CWD on left and the right side of the terminal.
Most helpful comment
More investigation needed but after stumbling on this:
https://www.bountysource.com/issues/48757141-failure-to-output-content-without-newline
I added
setopt prompt_spto my~/.zshrc(well I added it to the list) and this seems to work now.Inclined to say "working as expected" but I'm not sure if there are things to patch up re:themes and such.