FS#23492 - [pacman] behaves secretively in scripting mode

Attached to Project: Pacman
Opened by Tomas Mudrunka (harvie) - Tuesday, 29 March 2011, 04:38 GMT
Last edited by Dan McGee (toofishes) - Friday, 01 April 2011, 21:08 GMT
Task Type Bug Report
Category Output
Status Closed
Assigned To Dan McGee (toofishes)
Architecture All
Severity Medium
Priority Normal
Reported Version 3.5.1
Due in Version 3.5.2
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Summary and Info:
Pacman asks "Proceed with installation? [Y/n]" before telling me what he's going to do when it's in dumb-terminal mode (without progressbars, etc...)


Steps to Reproduce:

(Un/Re)Install some packages while redirecting pacman output somewhere
eg.:
# pacman -Syu | tee /tmp/paclog
or
# pacman -S xterm | tee /tmp/paclog
warning: xterm-269-1 is up to date -- reinstalling
resolving dependencies...
looking for inter-conflicts...
Proceed with installation? [Y/n] (NOTE that at this point i don't know what i am agreeing with!)

Targets (1): xterm-269-1

Total Download Size: 0.00 MB
Total Installed Size: 0.53 MB

checking package integrity...
checking for file conflicts...
checking available disk space...
upgrading xterm...
This task depends upon

Closed by  Dan McGee (toofishes)
Friday, 01 April 2011, 21:08 GMT
Reason for closing:  Fixed
Additional comments about closing:  Commit d8d89d8d27794
Comment by Dan McGee (toofishes) - Tuesday, 29 March 2011, 05:11 GMT
I have no idea what you are saying here. The question only appears on stderr and you are only redirecting stdout. What are you expecting? There is no secretive behavior here.
Comment by Xavier (shining) - Tuesday, 29 March 2011, 07:29 GMT
It looks like the ordering is messed up, which is probably caused by tee usage delaying stdout output or whatever.
Not sure what to do here.
Comment by Tomas Mudrunka (harvie) - Tuesday, 29 March 2011, 14:03 GMT
Xavier: fflush?
Comment by Tomas Mudrunka (harvie) - Tuesday, 29 March 2011, 14:07 GMT
There are lots of info on the web about how to flush both buffers (C and Terminal) to display something imediatelly...
But imho the newline should flush buffer, so maybe that problem is somewhere else...

Redirecting both FD's does not help:

[root@insomnia http]# LANG=C pacman -S xterm 2>&1 | tee /dev/paclog
warning: xterm-269-1 is up to date -- reinstalling
resolving dependencies...
looking for inter-conflicts...
Proceed with installation? [Y/n]

Targets (1): xterm-269-1

Total Download Size: 0.00 MB
Total Installed Size: 0.53 MB

checking package integrity...
checking for file conflicts...
checking available disk space...
upgrading xterm...
Comment by Dan McGee (toofishes) - Tuesday, 29 March 2011, 16:16 GMT
Well it turns out an fflush(stdout); addition does make this show up. I added it in display_targets(), but the more correct location might be at the beginning of any question display to ensure all output to that point has been displayed. Any thoughts?

$ sudo ./src/pacman/pacman -S xterm 2>&1 | tee /tmp/paclog
warning: xterm-269-1 is up to date -- reinstalling
resolving dependencies...
looking for inter-conflicts...

Targets (1): xterm-269-1

Total Download Size: 0.00 MB
Total Installed Size: 0.61 MB
Proceed with installation? [Y/n] ^C
Comment by Xavier (shining) - Tuesday, 29 March 2011, 20:02 GMT
I suppose we could fflush(stdout) in question() in the !noconfirm case (stream = stderr)

Loading...