Ask Your Question
2

Can you set dnf's prompt [Y/n] instead of [y/N]?

asked 2016-02-21 23:55:30 -0500

Is it possible to have dnf's confirmation prompt default to yes, but still prompt for confirmation?

The man page for dnf.conf mentions assumeyes which disables prompting completely, but this is not what I want to achieve.

Example dnf output:

Transaction Summary
================================================================================
Remove  19 Packages

Installed size: 137 M
Is this ok [y/N]:

I want to be asked

Is this ok [Y/n]:

and have it assume "yes" on return.

See also Bug 1289164 - [RFE] positive prompt answer by default

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
7

answered 2016-02-22 02:23:00 -0500

updated 2016-03-01 10:29:42 -0500

It turns out that there is a defaultyes option in the code that is currently undocumented.

To change from [y/N] to [Y/n] simply add this line to the [main] section of your /etc/dnf/dnf.conf:

defaultyes=True

EDIT: defaultyes as now been added to the docs and should show up in man dnf.conf for version 1.1.8.

edit flag offensive delete link more

Comments

Is this supposed to work in Fedora 22 with dnf version 1.1.6?

florian gravatar imageflorian ( 2016-02-24 16:15:58 -0500 )edit

@Florian Yes, its been in the code since Jan 2013 (I think it tagged version 0.6.4 but don't quote me on that)!

mattsturgeon gravatar imagemattsturgeon ( 2016-02-25 09:44:19 -0500 )edit

@mattsturgeon: Thanks for confirming. I've tried both defaultyes=True and defaultyes=1 in /etc/dnf/dnf.conf but it doesn't show any effect. Yes, I have rebooted in between. At what point of time is dnf reading the config? When executing a dnf command, right?

florian gravatar imageflorian ( 2016-02-25 20:04:05 -0500 )edit

@Florian Is it prompting at all? The function userconfirm() in dnf/cli/output.py gets run every time dnf asks for confirmation, unless assumeyes (or assumeno) is true.

userconfirm() then outputs either "Is this ok [y/N]: " or "Is this ok [Y/n]: " and loops until the user enters "yes", "y", "no" or "n" (or an empty string).

userconfirm() chooses which text to output based on self.conf.defaultyes which is set when dnf/yum/config.py parses dnf.conf

mattsturgeon gravatar imagemattsturgeon ( 2016-02-29 17:43:33 -0500 )edit

Yes, it is prompting Is this ok [y/N]: (I am not a big fan of assumeyes, so nothing set like this).

florian gravatar imageflorian ( 2016-02-29 21:52:15 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2016-02-21 23:01:51 -0500

Seen: 1,066 times

Last updated: Mar 01 '16