You are not logged in.
I was writing an wiki article and I needed the reader to install a couple of packages:
E.g.,
pacman -Sy first second
I use -y so pacman database will be updated, I'd also like that pacman answers 'n' to the question xxx: local is up to date upgrade anyway? automatically... is it possible?
Thanks
Offline
Read man pacman. The details of the --ask option are, uhm, enlightening.
For your purposes, you need the --noconfirm option.
Offline
--noconfirm answers `yes' to the question, not `no'...
And... man pacman about --ask is *really* well done. Yes... Patching time?
Offline
--noconfirm answers `yes' to the question, not `no'...
And... man pacman about --ask is *really* well done. Yes... Patching time?
Indeed, it's quite funny
I had a quick look at src/pacman/callback.c , and just setting --ask=0 will answer no to several questions, including the one you want.
Read the code for more details.
The ask value is just a flag, corresponding to this :
/* Transaction Conversations (ie, questions) */
typedef enum _pmtransconv_t {
PM_TRANS_CONV_INSTALL_IGNOREPKG = 0x01,
PM_TRANS_CONV_REPLACE_PKG = 0x02,
PM_TRANS_CONV_CONFLICT_PKG = 0x04,
PM_TRANS_CONV_CORRUPTED_PKG = 0x08,
PM_TRANS_CONV_LOCAL_NEWER = 0x10,
PM_TRANS_CONV_LOCAL_UPTODATE = 0x20,
PM_TRANS_CONV_REMOVE_HOLDPKG = 0x40
} pmtransconv_t;
So if you want to answer no to local uptodate and yes to these other questions, you need the following binary value :
1011111
which is 95 in decimal, so you can use --ask=95 .
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline
As an alternative that doesn't require binary math, try the yes command. It continuously writes the string you give it to stdout, so something like this should work:
yes n | pacman -Sy first second
If you know in advance what questions it will ask and the answers you want, you can do something like this:
(sleep 10 ; echo y ; sleep 5 ; echo n) | pacman -Sy first second
For anything more advanced, you'll need a tool like expect. Or the --ask option.
Offline
@shinning
Excellent and well done. This is exactly what I was expecting from --ask a simple set of answer where you can answer `no' with `zero' or `yes' with `one'.
Why not put that table in the manual?
Offline
Ehh.. the manual already says:
It is doubtful whether this option even works, so I would not recommend using it.
That's more than enough info for me....
Offline
I get the impression that --ask was inspired by the SysV 'pkgask'. I'm not sure that anybody uses that either
Offline
I brought up this issue on the ML :
http://www.archlinux.org/pipermail/pacm … 09111.html
and we are actually considering dropping this option, because it's too complicated, undocumented, and has a limited purpose.
I suppose you could still use skymt's workaround, or just let the user answer pacman's questions ?
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline
Why do you say it is complicated?
Using binary digit for making a set of positive answers is a nice idea!
About implementing better I can only ask you can put directly the binary number on the command line saving some binary calculus.
And of course copying the enum _pmtransconv_t idea in the man.
Of course you can let the user answer, but I often like giving answers in the command like directly...
Offline
Of course you can let the user answer, but I often like giving answers in the command like directly...
These questions asked by pacman might change, the pmtransconv_t might change as well.
This would break all your pacman commands using --ask, and would require you to update them every time.
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline