Conversation
…it b73ed5f7 git-subtree-dir: vendor/github.com/rcaloras/bash-preexec git-subtree-split: b73ed5f7f953207b958f15b1773721dded697ac3
git-vendor-name: preexec git-vendor-dir: vendor/github.com/rcaloras/bash-preexec git-vendor-repository: https://github.com/rcaloras/bash-preexec git-vendor-ref: 0.6.0
This reverts commit 7ab0074.
Technically, one can define a locale with decimal_point being an arbitrary string. For example, ps_AF seems to use U+066B as the decimal point Thanks @akinomyoga for the feedback
The subshell mentioned in the On the other hand, the code that this PR tries to fix is not used in a form I doubt |
The shell duration lib was not counting the duration between the start of a command to the end of that command, but from start of the prompt to the end of the next command. So the time was always wrong.
I maybe made a mental shortcut about this. But updating the preexec vendor and removing the sub-shell to get |
So you applied two changes to fix the problem. Have you checked that both changes are actually needed to fix the problem? In particular, does changing |
Just made a test case. The precedent version was 0.4.1. I see that you made several PR for this release (thank you). My test case is working after the PR 141 patch. |
akinomyoga
left a comment
There was a problem hiding this comment.
I was about to request separating the necessary changes and cosmetic changes (to make the intent of the changes clearer in the Git history), but I realized that this plugin was actually introduced by @BarbUk. Then, I wouldn't require explanations on the style changes, etc.
|
Thanks @akinomyoga for the time you took for this review. The command duration lib now works in microseconds directly.
It's configured at I'll try to add some bats test for the lib. |
Tests added. The tests showed there was still an issue with leading 0 while doing the microseconds truncate (same issue as this review: #2366 (comment)) |
|
Thanks again @akinomyoga for the review. Very nice and informative. I've fixed all points and added some bats tests to check how the code is handling the output when |
There was a problem hiding this comment.
Thank you for updating. The following is the remaining change that I suggested in the previous comment, but that might not be clear.
edit: Hmm, due to the GitHub interface, it still seems confusing. In the following three comments, I suggest the following change:
if ((minutes > 0)); then
printf "%s %s%dm %ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$minutes" "$seconds"
- elif ((COMMAND_DURATION_PRECISION > 0)); then
+ else
printf "%s %s%ss" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$seconds${microseconds:+.$microseconds}"
- else
- printf "%s %s%ds" "${COMMAND_DURATION_ICON:-}" "${COMMAND_DURATION_COLOR:-}" "$seconds"
fi
Yes, I did not understand it that way. I removed the unused code branch and added a new test case with precision 0 and microseconds time. |


Fix command duration lib to display the actual time a command took
Description
Motivation and Context
Command duration lib was updated in #2271 to fix an issue with the locale defined in the command duration lib.
The locale was forced to ensure that the decimal point of EPOCHREALTIME is the period.
The fix introduce a subshell, the preexec vendor has an issue with subshells:
https://github.com/rcaloras/bash-preexec/?tab=readme-ov-file#subshells
This PR update preexec to the last stable tag (0.6.0), update the command duration lib to remove the subshell and handle locale with period or comma.
How Has This Been Tested?
Before:
After:
Screenshots (if appropriate):
Before: left, after: right
Types of changes
Checklist:
clean_files.txtand formatted it usinglint_clean_files.sh.