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

Runtime fails if the slow command is not the first one in a pipeline #614

Closed
nolanl opened this issue Jul 3, 2020 · 3 comments
Closed
Labels
bash Related to Bash specific implemetation bug runtime Related to the generation and display of runtime of a command
Milestone

Comments

@nolanl
Copy link

nolanl commented Jul 3, 2020

Shell: bash 5.0.3(1)-release
Operating system: Linux 4.19.0-9-amd64 (2020-06-07), Debian GNU/Linux 10 (buster)
Liquidprompt version: 869d4ab

Steps to Reproduce

  1. Set LP_ENABLE_RUNTIME=1 and LP_RUNTIME_THRESHOLD=5
  2. sleep 2 | sleep 6

Expected Behavior

The prompt should report "6s".

Current Behavior

The prompt reports no time.

@nolanl nolanl added the bug label Jul 3, 2020
@Rycieos Rycieos added bash Related to Bash specific implemetation help wanted An issue where ideas or patches are welcome labels Jul 4, 2020
@Rycieos
Copy link
Collaborator

Rycieos commented Jul 4, 2020

I can confirm this, bash 4.4.19(1)-release.

Zsh doesn't seem to have this problem.

This is a really interesting one, nice find. I'll have to do some digging, but this might end up being a bash bug, in which case I'm not sure we can fix it.

@Rycieos Rycieos added this to the v1.12 milestone Jul 7, 2020
@Rycieos Rycieos added runtime Related to the generation and display of runtime of a command and removed help wanted An issue where ideas or patches are welcome labels Jul 7, 2020
@Rycieos Rycieos closed this as completed in 4a9169e Jul 7, 2020
@Rycieos
Copy link
Collaborator

Rycieos commented Jul 7, 2020

Fixed on master and in v1.12-rc.1. This would not have been easy to fix if I hadn't learned quite a bit working on #451.

Rycieos added a commit that referenced this issue Jul 7, 2020
If the user hits enter on a empty prompt, Bash doesn't execute a
command, so it doesn't call the DEBUG trap. This means the DEBUG trap
for the $PROMPT_COMMAND would be the first, and it was catching the
"start of command" path, and not the "end of command" path. This meant
the next empty return would take the "end of command" path, and display
a runtime.

Remove the `elif`, and make the one DEBUG call possible to go down both
paths.

Related #614
@Rycieos
Copy link
Collaborator

Rycieos commented Jul 7, 2020

Ok, this wasn't a complete fix. Turns out that if you hit enter on an empty prompt, Bash runs $PROMPT_COMMAND, but since it doesn't run any command, it doesn't run a DEBUG trap for the non-existant command. Duh. This means if you press enter twice on an empty prompt, it will show timing on the second one (if enough time passed). Fixed in 25cd5dc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bash Related to Bash specific implemetation bug runtime Related to the generation and display of runtime of a command
Projects
None yet
Development

No branches or pull requests

2 participants