FS#14724 - Option to change pacman's default action from 'yes' to 'no'
Attached to Project:
Pacman
Opened by Dan Murphy (BlackSwan) - Friday, 15 May 2009, 15:06 GMT
Last edited by Andrew Gregory (andrewgregory) - Wednesday, 11 March 2015, 20:43 GMT
Opened by Dan Murphy (BlackSwan) - Friday, 15 May 2009, 15:06 GMT
Last edited by Andrew Gregory (andrewgregory) - Wednesday, 11 March 2015, 20:43 GMT
|
Details
Description: Pacman asks you for confirmation when
installing or removing packages, and the default answer is
'yes' (i.e. [Y/n]). It would be nice to have the option
(presumably via a setting in /etc/pacman.conf) to make the
default answer 'no' ([y/N]).
I think users would appreciate have the option since the [y/N] behavior is arguably safer, and is consistent with other popular package managers (notably yum). |
This task depends upon
Closed by Andrew Gregory (andrewgregory)
Wednesday, 11 March 2015, 20:43 GMT
Reason for closing: Won't implement
Wednesday, 11 March 2015, 20:43 GMT
Reason for closing: Won't implement
Defaulting to 'no' is sane for programs that can potential break your system (package managers, partitioners, filesystem utilities, etc.)
Good point. I can see most people feeling the same. An option in pacman.conf to control the default would be nice.
The problem is, that pacman doesn't use a _general_ default answer, the default answer depends on the actual operation and we have to keep in mind, that --noconfirm always "choose" the default answer. The default answer is no with "dangerous" operation only (HoldPkg etc.), I don't see why we should default to no, when the _user_ runs "pacman -R foo"...
partitioners and filesystem utilities are much more dangerous imo. It can damage your data, and it's often very difficult, even nearly impossible to get it back.
package managers in the worst case make your system unbootable, nothing that you cannot repair by booting in another *nix system (which can be a livecd) and fix things there. Well there are some cases where this is not practical, eg with remote servers, but then the incompetence of a server admin is not pacman's fault.
What Nagy said is also very important : the default action is not always yes, it depends on the question.
We could still have one simple option which says the default action will be no for all the questions, but well..
Attached a sample txt file with all the current defaults.
If we allow this, would probably be a good idea to list the pros and cons of changing each option. Otherwise, make sure the default option in official pacman is always the safer option.
But do we really want that? Do we need this complexity?
Who is going to implement this to satisfy 2 users who have a very special need?
Are all of the current defaults safe or are they just (semi)sensible "I said -Su damnit!" defaults?
My main concern here is that if we do change any defaults without adding flexibility is that automated scripts might not get the results they used to get. Changing expected behaviour is usually bad in the short term.
I don't see any reason to change them and break the existing pacman wrappers.
People in my position (constantly switching between package managers) should probably just get in the habit of always typing 'y' or 'n' instead of relying on default choices.
As suggested in thread closing comment, I have created the necessary patch (attached with the comment) for this.
Requesting to open this thread and apply patch after testing.
(NOTE: Comment below is long but I am just trying to describe properly, actual patch is small - just 11 new lines added in total)
First I would like to mention that this patch does NOT change the default behaviour.
So I request to those who have objection to this feature, please do not to object, as it does not change anything for you. Thank you :-)
Details about this patch:
1) Patch just adds one OPTIONAL directive called "DefaultAnswer". (pacman.conf)
2) If its not specified, it just behaves like current behaviour.
3) Value of DefaultAnswer can be "smart" (default) or "safe"
4) "smart" means just like current behaviour i.e. pacman decides smartly if default answer should be Yes or No.
5) "safe" means pick option which does not change anything in system. (conservative approach)
6) If safe is on, Answer to question on -U, -R, -S etc will default to NO (except when importing keys which by default is yes)
7) This option can also help new users to learn pacman and prevent accidents when they are learning.
8) noconfirm overrides this, So existing scripts should not have problem even if DefaultAnswer is set to "safe" in pacman.conf
9) Looking at code I noticed that there are two EXACTLY same functions called yesno() and noyes().
i.e. just difference is yesno has YES default, noyes has NO default.
About 7-8 lines of code is redundant.
10) So I have merged these two function in single function called yesno(int preset, ...).
If preset is 1 it is equivalent to yesno(), if preset is 0 it is equivalent to noyes()
11) This same modified yesno() function NOW decides what to do based on DefaultAnswer.
Basically there is not much logical change in yesno() code (minor 3-4 line change, overall just 11 lines added).
Once again - default behaviour is same as it is right now.
So please accept the patch and apply it to master.
Thank you.
We want safer defaults. By your logic I can say, why even ask for confirmation at all when you just told pacman to something why not simply do it?
Everyone does alias rm='rm -i', why? To be little bit safer. Pressing simply Enter defaults to NO even in rm.
Sometimes I just want to see what packages will be downloaded (as dependency). If I remove package what else will get affected (what depends on it). etc. etc. (I dont really want to do anything!)
I know there are other ways but I dont want to remember multiple commands (like checkupdates).
All I want is one command does it all. All I want to remember is -S and -R thats all (and their sub-commands)
Atleast it makes my life easier. I already have so many other commands to remember. Hence I am looking for safer defaults.
I am not saying change the existing behaviour but atleast give us option.
DefaultAnswer = nodefault
which will mean that user will HAVE to type y or n and there will be no default.
But I left it AS IS, because I felt that many users would object to that. There are already so many objections that one more objection would cause rejection of patch, so I tried to play safe.
But I think, whatever you do, there will be some people who will say this is not required, this is not how it should be.
3-4 people here wanted safe option, developers asked for patch. I created patch.
I have put my case, to accept it or not is left to developers. Thanks :)
DefaultAnswer = nodefault means There will be no default answer, user has to specify yes or no. (noconfirm still overrides this)
The patch also fixes a minor bug in question() function.
On keyboard H is right in between Y and N, So if user types say H (by mistake), it takes it as N. (Does not matter if default is Y or N).
Anything other than Y (or yes) is taken as No. Now I dont know if that is correct on function level.(Function does not know what question is so can not assume that wrong input always means No)
So I fixed this as well. If user types anything other then Y or N, it asks again.
Thanks and regards.
Here you are trying to find complete solution before implementing and taking user opinions. That too for a feature which is not even enabled by default. (So its not like its going to cause major problems for Arch users)
The end-users who want this "safe" feature, atleast they get MAIN defaults as safe. Something is better than nothing right?
I will say implement the feature, if users think that certain "safe" option is not really safe let them file bug reports. Then we can re-view.
But since he had asked someone to create a patch, which he will review, here I am again. Attached is the patch for 4.2.0.
What patch does is already described in my earlier posts above
In summary:
1) Patch adds option called DefaultAnswer = smart|safe|nodefault. "smart" is default and functionality remains as if patch is not applied.
2) Currently if user presses invalid key by mistake (say H i.e. neither Y nor N) then it assumes Yes. I have fixed this as well.
3) Two almost identical functions yesno and noyes are replaced by one single function yesno
So requesting again to consider the feature.
Thank you
PS: Using the patch from about 8 months.