PDA

View Full Version : yum default answer for everythign is 'no'



cell
6th June 2006, 06:19 PM
Is there a way to change the default answer for yum's questions to 'yes'? I understand the idea of prompting the user with 'are you sure?' instead of simply doing what they ask, but prompting the user *and* making the default answer 'no' is more than a little bit absurd.

pparks1
6th June 2006, 06:23 PM
Instead of changing the default, I usually issue a command like this

yum -y update

The -y just answers yes for you. You could also make a command alias that changes regular yum to yum -y if you don't want to bother with the -y

markjensen
6th June 2006, 06:24 PM
It may not be a good idea to force a "yes" to every yum action: http://forums.fedoraforum.org/showthread.php?p=544447#post544447

However, if you really want to, I am pretty sure you could set up an alias for it.

Try alias yum='yum -y'
then do a yum install of some trivial package, to make sure it installs without prompting.

cell
6th June 2006, 06:38 PM
The '-y' option not only changes the default answer, but also answers the question for you. That's not what I want.

Essentially, yum is asking 'would you like to cancel?', but I want it to ask 'are you sure?'

cell
6th June 2006, 06:56 PM
wow, this is hard-coded into yum. lame. I wrote a work-around patch for /usr/share/yum-cli/output.py.


--- output.py.orig 2006-06-06 12:44:39.000000000 -0500
+++ output.py 2006-06-06 12:52:01.000000000 -0500
@@ -111,18 +111,18 @@


def userconfirm(self):
- """gets a yes or no from the user, defaults to No"""
+ """gets a yes or no from the user, defaults to Yes"""

while True:
- choice = raw_input('Is this ok [y/N]: ')
+ choice = raw_input('Is this ok [Y/n]: ')
choice = choice.lower()
if len(choice) == 0 or choice[0] in ['y', 'n']:
break

- if len(choice) == 0 or choice[0] != 'y':
- return False
- else:
+ if choice[0] == 'y' or len(choice) == 0:
return True
+ else:
+ return False


def displayPkgsInGroups(self, group):

cell
6th June 2006, 08:18 PM
I wrote a different patch which makes this a configurable option, and submitted a bug.

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=194270


--- /usr/share/yum-cli/output.py.orig 2006-06-06 12:44:39.000000000 -0500
+++ /usr/share/yum-cli/output.py 2006-06-06 13:32:59.000000000 -0500
@@ -111,18 +111,29 @@


def userconfirm(self):
- """gets a yes or no from the user, defaults to No"""
+ """gets a yes or no from the user"""
+
+ if self.conf.default_is_no:
+ prompt = 'Is this ok [y/N]: '
+ else:
+ prompt = 'Is this ok [Y/n]: '

while True:
- choice = raw_input('Is this ok [y/N]: ')
+ choice = raw_input(prompt)
choice = choice.lower()
if len(choice) == 0 or choice[0] in ['y', 'n']:
break

- if len(choice) == 0 or choice[0] != 'y':
- return False
- else:
+ if len(choice) == 0:
+ if self.conf.default_is_no:
+ choice = 'n'
+ else:
+ choice = 'y'
+
+ if choice[0] == 'y':
return True
+ else:
+ return False


def displayPkgsInGroups(self, group):
--- /usr/lib/python2.4/site-packages/yum/config.py.orig 2006-06-06 13:04:13.000000000 -0500
+++ /usr/lib/python2.4/site-packages/yum/config.py 2006-06-06 13:07:04.000000000 -0500
@@ -512,6 +512,7 @@
tsflags = ListOption()

assumeyes = BoolOption(False)
+ default_is_no = BoolOption(True)
alwaysprompt = BoolOption(True)
exactarch = BoolOption(True)
tolerant = BoolOption(True)

Jman
7th June 2006, 04:38 AM
I don't find a default of no to be unreasonable. It is safe to do, especially with a remove operation. I do use the -y option for trivial installs, however.