You are not logged in.

#1 2011-09-05 07:14:18

Spyhawk
Member
Registered: 2006-07-07
Posts: 485

pacman autoconfirm with "yes" misses a new line

Hi there,

I'm trying to add some code to an aur helper that allows autoconfirm pacman request automatically when it come across a packages conflict.
The objective is to obtain a fast workflow operation at the execution, while the package conflict itself is handled way before the package got compiled.

The "yes" command is used to bypass pacman default answer, however the output doesn't look that great:

$ sudo sh -c "yes | pacman-color -U /var/cache/pacman/pkg/cower-3.0.5-1-i686.pkg.tar.xz"
resolving dependencies...
looking for inter-conflicts...
:: cower and cower-git are in conflict. Remove cower-git? [y/N] 
Remove (1): cower-git-20110905-1 [0.10 MB]

Total Removed Size:   0.10 MB

Targets (1): cower-3.0.5-1 [0.02 MB]

Total Download Size:    0.00 MB
Total Installed Size:   0.10 MB

Proceed with installation? [Y/n] (1/1) checking package integrity                                                      [##################################################] 100%
(1/1) checking for file conflicts                                                     [##################################################] 100%
(1/1) removing cower-git                                                              [##################################################] 100%
(1/1) installing cower                                                                [##################################################] 100%

There is a missing newline after each of the bypassed prompt. I tried with the following without more success:

$ sudo sh -c "yes y$'\n' | pacman <command>"

Not really an important bug, but maybe someone here got an idea how to improve output? Does pacman itself needs to be patched to handle this?

Thanks in advance.

Last edited by Spyhawk (2011-09-05 21:52:25)

Offline

#2 2011-09-05 07:33:58

Allan
Member
From: Brisbane, AU
Registered: 2007-06-09
Posts: 10,828
Website

Re: pacman autoconfirm with "yes" misses a new line

Instead of yes, you can use

      --noconfirm      do not ask for any confirmation

Offline

#3 2011-09-05 07:35:40

Spyhawk
Member
Registered: 2006-07-07
Posts: 485

Re: pacman autoconfirm with "yes" misses a new line

--noconfirm is going to answer "No" to the package conflict prompt, which is exactly what I want to avoid smile

Last edited by Spyhawk (2011-09-05 07:36:05)

Offline

#4 2011-09-05 07:45:00

Allan
Member
From: Brisbane, AU
Registered: 2007-06-09
Posts: 10,828
Website

Re: pacman autoconfirm with "yes" misses a new line

Ah -- good point...   I entirely missed that.

Offline

#5 2011-09-05 13:34:37

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: pacman autoconfirm with "yes" misses a new line

I've noticed that pacman isn't the only app to exhibit this behavior:

[karol@black ~]$ echo "n" | rm test
rm: remove regular file `test'? [karol@black ~]$ 
[karol@black ~]$ echo "n" | rm test && echo -e "\r"
rm: remove regular file `test'?
[karol@black ~]$ 

When using 'yes' instead of echo, same problems, same solution / workaround.

Last edited by karol (2011-09-05 13:36:20)

Offline

#6 2011-09-05 21:51:25

Spyhawk
Member
Registered: 2006-07-07
Posts: 485

Re: pacman autoconfirm with "yes" misses a new line

Thanks karol for your answer,

However, it seems I obtain the very same output as above even when using

sudo sh -c "yes | pacman-color <command> && echo \"\r\""

What I really don't understand is that "yes" command allows a new line to be echoed but it is not taken into account:

$ yes
y
y
y
y
y
y
...

$ yes y$'\n'
y 

y

y

y
...

Offline

#7 2011-09-05 22:04:35

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: pacman autoconfirm with "yes" misses a new line

"Works" here:

[karol@black ~]$ echo "n" | pacman -S qt && echo -e "\r"
resolving dependencies...
looking for inter-conflicts...

Targets (1): qt-4.7.4-1 [24,75 MB]

Total Download Size:    0,00 MB
Total Installed Size:   102,86 MB

Proceed with installation? [Y/n] 
[karol@black ~]$ 

"Works" with 'yes' too:

[karol@black ~]$ yes | pacman -S qt && echo -e "\r"
resolving dependencies...
looking for inter-conflicts...

Targets (1): qt-4.7.4-1 [24,75 MB]

Total Download Size:    0,00 MB
Total Installed Size:   102,86 MB

Proceed with installation? [Y/n] (0/1) checking package integrity                           [-----
(1/1) checking package integrity                           [################################] 100%
(1/1) checking for file conflicts                          [################################] 100%
(1/1) checking available disk space                        [################################] 100%
(1/1) installing qt                                        [################################] 100%
Optional dependencies for qt
    postgresql-libs: PostgreSQL driver
    libmysqlclient: MySQL driver
    unixodbc: ODBC driver
    libxinerama: Xinerama support
    libxcursor: Xcursor support
    libxfixes: Xfixes support

[karol@black ~]$ 

but have you noticed

Proceed with installation? [Y/n] (0/1) checking package integrity                           [-----

- the carriage return gets eaten here.



Could it be related to https://bugs.archlinux.org/task/20538 ?

Last edited by karol (2011-09-05 22:10:37)

Offline

#8 2011-09-06 08:41:54

Spyhawk
Member
Registered: 2006-07-07
Posts: 485

Re: pacman autoconfirm with "yes" misses a new line

karol wrote:

- the carriage return gets eaten here.

Could it be related to https://bugs.archlinux.org/task/20538 ?

Yeah, that might be related to that bug/feature. Any pacman dev to confirm? :]

Offline

#9 2011-09-06 10:12:01

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,109
Website

Re: pacman autoconfirm with "yes" misses a new line

Seems unlikely. Comment out the calls to flush_term_input in src/pacman/util.c and see what happens.

Offline

#10 2011-09-06 12:10:03

Spyhawk
Member
Registered: 2006-07-07
Posts: 485

Re: pacman autoconfirm with "yes" misses a new line

falconindy wrote:

Seems unlikely. Comment out the calls to flush_term_input in src/pacman/util.c and see what happens.

Yup. Done that, same problem. That bug isn't related to flush term, but something else :]

Offline

#11 2012-01-12 03:54:05

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: pacman autoconfirm with "yes" misses a new line

Bug reported by Spyhawk https://bugs.archlinux.org/task/27909

Offline

#12 2012-01-12 18:56:11

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 858
Website

Re: pacman autoconfirm with "yes" misses a new line

In case people are confused about why this happens, here's what's going on:

printf("Normal output\n");
printf("A prompt: ");
scanf("%s", str);

The prompt doesn't print \n because you usually type one.  That is, you press enter, and that makes a newline.

When you do yes | pacman, the output of yes doesn't get echoed to the screen, so you don't see the \n provided by yes.

One fix is to do something like "if (!isatty(STDIN_FILENO)) printf("\n");" after every prompt.  But to me, it's not a bug since most programs work like this.

Offline

#13 2019-02-07 12:10:02

khvalera
Member
Registered: 2015-11-17
Posts: 2

Re: pacman autoconfirm with "yes" misses a new line

https://forum.manjaro.org/t/force-pacma … ges/2272/9


   YES_CHAR="$(pacman -Sddw bash --noconfirm | grep '? \[' | cut -d"[" -f2 | cut -d"/" -f1)"

    yes "$YES_CHAR" | pacman -S --confirm freetype2-infinality-ultimate fontconfig-infinality-ultimate cairo-infinality-ultimate

Offline

#14 2019-02-07 12:31:42

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 6,468

Re: pacman autoconfirm with "yes" misses a new line

Don't necrobump with commands that don't have relevance to Arch.

https://wiki.archlinux.org/index.php/Co … ort_*only*

https://wiki.archlinux.org/index.php/Co … bumping%22

Closing.

Offline

Board footer

Powered by FluxBB