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

-vb duplicates progress bar output #53

Open
CarstenGrohmann opened this issue Jun 6, 2017 · 3 comments
Open

-vb duplicates progress bar output #53

CarstenGrohmann opened this issue Jun 6, 2017 · 3 comments

Comments

@CarstenGrohmann
Copy link

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

@hoytech
Copy link
Owner

hoytech commented Jun 6, 2017

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!

@pfee
Copy link

pfee commented Apr 14, 2022

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.

@pfee
Copy link

pfee commented Apr 15, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants