-vb duplicates progress bar output
Hi,
if you run vmtouch -vb the progress bar lines are added twice to the output file. It would be great if the lines just occur once.
Steps to reproduce:
# fgrep -r "foobarHURZ" /usr/
# find /usr/ -type f | vmtouch -vb - > vmtouch.out
# less vmtouch.out
/usr/lib/libxcb-xv.so.0.0.0
^M[OOOOOOOO] 8/8^M[OOOOOOOO] 8/8
/usr/lib/libXext.so.6.4.0
^M[OOOOOOOOOOOOOOOOOOO] 19/19^M[OOOOOOOOOOOOOOOOOOO] 19/19
/usr/lib/libX11-xcb.so.1.0.0
^M[OO] 2/2^M[OO] 2/2
[...]
# cat vmtouch.out | tr '\r' '\n'
/usr/lib/libxcb-xv.so.0.0.0
[OOOOOOOO] 8/8
[OOOOOOOO] 8/8
/usr/lib/libXext.so.6.4.0
[OOOOOOOOOOOOOOOOOOO] 19/19
[OOOOOOOOOOOOOOOOOOO] 19/19
/usr/lib/libX11-xcb.so.1.0.0
[...]
Regards, Carstem
Hi,
The reason you're seeing two is that it tries to show an interactive progress bar while touching, by printing "\r" to go back to the beginning of the line and overwriting with a new progress bar. I believe it does this at the beginning and the end of processing each file, which is why you're seeing 2 even though you're not touching (just displaying).
I agree this looks like a bug. I'll think about the best way to solve this and update this ticket when I do.
In the meantime, you can eliminate the excess lines with the following:
cat vmtouch.out | perl -pe 's/^.*\r//'
Thanks for the report!
I've encountered the same issue, reproduced with:
$ vmtouch -v /usr/bin/ls | cat -v
/usr/bin/ls
^M[OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO] 33/33^M[OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO] 33/33
Files: 1
Directories: 0
Resident Pages: 33/33 132K/132K 100%
Elapsed: 0.000152 seconds
My use case is to regularly display vmtouch output using the watch utility.
$ watch -n 1 vmtouch -v growing_file.bin
Having output repeated twice is undesirable. Perhaps vmtouch could have a flag to disable the interactive progress bar and its use of \r.
Having looked at the code, the carriage return characters can be eliminated for the case where -v is used on the command line without -t. The changes are available in pull request #97.