digint / btrbk

Tool for creating snapshots and remote backups of btrfs subvolumes
https://digint.ch/btrbk/
GNU General Public License v3.0
1.58k stars 116 forks source link

progress line -- cleanup until the end of line #548

Open yarikoptic opened 11 months ago

yarikoptic commented 11 months ago

now (0.32.5-1) progress line might look like

in @ 2045 kiB/s, out @ 2045 kiB/s, 18.5 GiB total, buffer 100% fullll

because numbers might vary in width and we keep accumulating those "l"s at the end.

Solution could probably be use of ANSI character \033[0K, e.g.

❯ for n in 123 23 1; do echo -ne "\rline $n"; done; echo
line 133
❯ for n in 123 23 1; do echo -ne "\rline $n\033[0K"; done; echo
line 1

my perl is so bad that I didn't decide to try for a PR... actually I did but failed to find code where to add ;-)