mirror of
https://github.com/dustinkirkland/byobu
synced 2025-07-05 20:42:10 -07:00
Description: strip time EPOCHREALTIME by digit not decimal separator
original code stripped only by period defined decimal. Some locales separate by comma. The goal is to strip to a non-decimal, so instead only allowing digits, and using start of string ensures safety. Author: Jakub Skopal <jakub.skopal@bindworks.eu> Origin: uptream, https://github.com/dustinkirkland/byobu/pull/71 Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/byobu/+bug/2052610 Reviewed-by: John Chittum <john.chittum@canonical.com> Last-Update: 2025-03-03
This commit is contained in:
parent
d315ccbd89
commit
2ca86a554d
1 changed files with 4 additions and 3 deletions
|
@ -37,8 +37,9 @@ byobu_prompt_runtime() {
|
|||
local starttime endtime duration days hours minutes seconds microseconds nanoseconds str
|
||||
[ ! -r $BYOBU_RUN_DIR/timer.$$ ] && printf "[0.000s]" && return
|
||||
read starttime < $BYOBU_RUN_DIR/timer.$$ 2>/dev/null || true
|
||||
endtime=${EPOCHREALTIME/./}
|
||||
starttime=${starttime/./}
|
||||
# strip to non-decimal time. avoids LP: #2052610
|
||||
endtime=${EPOCHREALTIME/[^0-9]/}
|
||||
starttime=${starttime/[^0-9]/}
|
||||
duration=$((endtime - starttime))
|
||||
days=$((duration/1000000/60/60/24))
|
||||
hours=$((duration/1000000/60/60%24))
|
||||
|
@ -55,7 +56,7 @@ byobu_prompt_runtime() {
|
|||
printf "[%s] " "$str" 1>&2
|
||||
}
|
||||
# Requires Bash 4.x
|
||||
export PS0='$(printf "%s" ${EPOCHREALTIME/./} >"$BYOBU_RUN_DIR/timer.$$")'
|
||||
export PS0='$(printf "%s" ${EPOCHREALTIME/[^0-9]/} >"$BYOBU_RUN_DIR/timer.$$")'
|
||||
|
||||
case "$BYOBU_DISTRO" in
|
||||
"Ubuntu")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue