Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Minor: missing newline after status output #414

Closed
fgtham opened this issue Feb 10, 2023 · 5 comments · Fixed by #415
Closed

[BUG] Minor: missing newline after status output #414

fgtham opened this issue Feb 10, 2023 · 5 comments · Fixed by #415
Assignees

Comments

@fgtham
Copy link

fgtham commented Feb 10, 2023

Describe the bug

The pueue status command output is missing a final newline:

$ pueue status
Group "default" (2 parallel): running

Task list is empty. Add tasks with `pueue add -- [cmd]`$ 

$ pueue add -- 'sleep 1'
New task added (id 0).
$ pueue status
Group "default" (2 parallel): running
──────────────────────────────────────────────────────────
 Id   Status    Command   Path        Start      End      
══════════════════════════════════════════════════════════
 0    Success   sleep 1   /home/flo   08:50:38   08:50:40 
──────────────────────────────────────────────────────────$ 

Steps to reproduce the bug

Just run pueue status.

Expected behavior

I would expect a final newline, so that the command prompt is at the beginning of a new line:

$ pueue status
Group "default" (2 parallel): running
──────────────────────────────────────────────────────────
 Id   Status    Command   Path        Start      End      
══════════════════════════════════════════════════════════
 0    Success   sleep 1   /home/flo   08:50:38   08:50:40 
──────────────────────────────────────────────────────────
$ 

Additional context

  • Gentoo Linux
  • Pueue version: Pueue client 3.1.0
@Nukesor
Copy link
Owner

Nukesor commented Feb 10, 2023

I'm actually unable to reproduce this behavior.

This works perfectly fine on the newest 3.1.0 release on all shells I tested, including GNU bash sh 5.1.16 and zsh 5.9.

What kind of shell are you using?

The fact that we didn't change anything in the way status is being displayed since a few versions makes me assume that this might be some kind of misconfiguration or user environment error.

@fgtham
Copy link
Author

fgtham commented Feb 10, 2023

What kind of shell are you using?

bash 5.1.16(1) on Gentoo and 5.1.4 on Debian. I run the precompiled pueue(d) binaries on all machines.

The fact that we didn't change anything in the way status is being displayed since a few versions makes me assume that this might be some kind of misconfiguration or user environment error.

It used to work fine in the previous version 3.0.1 (and all previous ones).

To exclude misconfiguration or user environment issues on my part, I spun up a virtual machine and started a Ubuntu 22.10 live session. I downloaded the pueue(d) binaries for versions 3.0.1 and 3.1.0 and executed them:

ubuntu@ubuntu:~$ ./pueued-linux-x86_64-3.0.1 &
ubuntu@ubuntu:~$ ./pueue-linux-x86_64-3.0.1 | hexdump -C
00000000  47 72 6f 75 70 20 22 64  65 66 61 75 6c 74 22 20  |Group "default" |
00000010  28 31 20 70 61 72 61 6c  6c 65 6c 29 3a 20 72 75  |(1 parallel): ru|
00000020  6e 6e 69 6e 67 0a 0a 54  61 73 6b 20 6c 69 73 74  |nning..Task list|
00000030  20 69 73 20 65 6d 70 74  79 2e 20 41 64 64 20 74  | is empty. Add t|
00000040  61 73 6b 73 20 77 69 74  68 20 60 70 75 65 75 65  |asks with `pueue|
00000050  20 61 64 64 20 2d 2d 20  5b 63 6d 64 5d 60 0a     | add -- [cmd]`.|
0000005f

Note the final \0x0a new line character in the above output.

ubuntu@ubuntu:~$ ./pueued-linux-x86_64-3.1.0 &
ubuntu@ubuntu:~$ ./pueue-linux-x86_64-3.1.0 | hexdump -C
00000000  47 72 6f 75 70 20 22 64  65 66 61 75 6c 74 22 20  |Group "default" |
00000010  28 31 20 70 61 72 61 6c  6c 65 6c 29 3a 20 72 75  |(1 parallel): ru|
00000020  6e 6e 69 6e 67 0a 0a 54  61 73 6b 20 6c 69 73 74  |nning..Task list|
00000030  20 69 73 20 65 6d 70 74  79 2e 20 41 64 64 20 74  | is empty. Add t|
00000040  61 73 6b 73 20 77 69 74  68 20 60 70 75 65 75 65  |asks with `pueue|
00000050  20 61 64 64 20 2d 2d 20  5b 63 6d 64 5d 60        | add -- [cmd]`|
0000005e

The final new line character is missing. The same happens with a non-empty task list. Good in version 3.0.1:

ubuntu@ubuntu:~$ ./pueue-linux-x86_64-3.0.1 status
Group "default" (1 parallel): running
─────────────────────────────────────────────────────────────
 Id   Status    Command   Path           Start      End      
═════════════════════════════════════════════════════════════
 0    Success   sleep 1   /home/ubuntu   18:00:52   18:00:53 
─────────────────────────────────────────────────────────────
 1    Success   sleep 2   /home/ubuntu   18:02:22   18:02:25 
─────────────────────────────────────────────────────────────
ubuntu@ubuntu:~$ 

Broken in version 3.1.0:

ubuntu@ubuntu:~$ ./pueue-linux-x86_64-3.1.0 status
Group "default" (1 parallel): running
─────────────────────────────────────────────────────────────
 Id   Status    Command   Path           Start      End      
═════════════════════════════════════════════════════════════
 0    Success   sleep 1   /home/ubuntu   18:00:52   18:00:53 
─────────────────────────────────────────────────────────────
 1    Success   sleep 2   /home/ubuntu   18:02:22   18:02:25 
─────────────────────────────────────────────────────────────ubuntu@ubuntu:~$ 

Without knowing anything about the code, to me it looks like there are some missing newlines in
pueue/src/client/display/state.rs. Maybe they fell off during the change from println!("...") to output.push_str("\n..."), e.g. in lines L84 vs R88 and a few others?

@fgtham
Copy link
Author

fgtham commented Feb 11, 2023

Also, it seems that zsh tries to preserve partial lines when emitting the prompt by default. Maybe this behaviour masked the visibility of the reported issue.

@Nukesor
Copy link
Owner

Nukesor commented Feb 12, 2023

You were completely right, there was actually a change between v3.0.1 and v3.1.0.
The new version used print! instead of println!, which adds a newline at the end.

I'm still confused that we're getting different behaviors on the same bash version accross systems, as I'm still unable to reproduce the behavior that can be observed on your machines.
My local bash is also bare-bones completely unconfigured, so there shouldn't be anything different to your setup.
Sorry for being sceptical at first.

Anyhow. The usage of println! should actually fix this behavior, could you check the MR #415, whether this works for you :)?

git clone https://github.com/Nukesor/pueue
cd pueue
git switch fix-newlines
cargo install --path ./pueue

@fgtham
Copy link
Author

fgtham commented Feb 12, 2023

Yes, it's strange that bash seems to behave differently. It would be really interesting to know the cause. Anyway, thanks for digging into the issue, the MR makes the new lines reappear:

$ .cargo/bin/pueue
Group "default" (2 parallel): running

Task list is empty. Add tasks with `pueue add -- [cmd]`
$

I looked at several other status and log outputs, they are all fine. Thanks, very much appreciated!

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 a pull request may close this issue.

2 participants