[pacman-dev] [PATCH] Remove -f short option for --force

Dan McGee dan at archlinux.org
Wed Oct 12 15:11:41 EDT 2011


This is not something that should be used on a frequent basis, and
giving it a short option encourages use without making the drawbacks
obvious. For the 1% of situations that require it, the 5 extra
keystrokes are a fair price to pay.

Signed-off-by: Dan McGee <dan at archlinux.org>
---

Dave, Ionuț, and I are getting a bit fed up with people abusing this option and
not realizing it skips a lot more than they think- if files move between
packages, using this option will likely leave your system in a state you did
not expect.

Removing the short option for it at least makes people read the word "force"
and maybe they will have some sense to step back and think about what they are
doing first.

If we do decide to do this, I will update the *completion files which I just
realized I did not do. I can also add in the pactests showing the difference
between an -Su and -Suf operation when files change between packages.

 doc/pacman.8.txt    |    2 +-
 src/pacman/conf.h   |    3 ++-
 src/pacman/pacman.c |    6 +++---
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt
index 5985381..39551e1 100644
--- a/doc/pacman.8.txt
+++ b/doc/pacman.8.txt
@@ -201,7 +201,7 @@ Transaction Options (apply to '-S', '-R' and '-U')
 
 Upgrade Options (apply to '-S' and '-U')[[UO]]
 --------------------------------------------
-*-f, \--force*::
+*\--force*::
 	Bypass file conflict checks and overwrite conflicting files. If the
 	package that is about to be installed contains files that are already
 	installed, this option will cause all those files to be overwritten.
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 9e14925..325fbb6 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -128,7 +128,8 @@ enum {
 	OP_PRINTFORMAT,
 	OP_GPGDIR,
 	OP_RECURSIVE,
-	OP_DBONLY
+	OP_DBONLY,
+	OP_FORCE
 };
 
 /* clean method */
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index d14b887..0326ef1 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -180,7 +180,7 @@ static void usage(int op, const char * const myname)
 		switch(op) {
 			case PM_OP_SYNC:
 			case PM_OP_UPGRADE:
-				addlist(_("  -f, --force          force install, overwrite conflicting files\n"));
+				addlist(_("      --force          force install, overwrite conflicting files\n"));
 				addlist(_("      --asdeps         install packages as non-explicitly installed\n"));
 				addlist(_("      --asexplicit     install packages as explicitly installed\n"));
 				addlist(_("      --ignore <pkg>   ignore a package upgrade (can be used more than once)\n"));
@@ -533,7 +533,7 @@ static int parsearg_upgrade(int opt)
 	if(parsearg_trans(opt) == 0)
 		return 0;
 	switch(opt) {
-		case 'f': config->flags |= ALPM_TRANS_FLAG_FORCE; break;
+		case OP_FORCE: config->flags |= ALPM_TRANS_FLAG_FORCE; break;
 		case OP_ASDEPS: config->flags |= ALPM_TRANS_FLAG_ALLDEPS; break;
 		case OP_ASEXPLICIT: config->flags |= ALPM_TRANS_FLAG_ALLEXPLICIT; break;
 		case OP_NEEDED: config->flags |= ALPM_TRANS_FLAG_NEEDED; break;
@@ -599,7 +599,6 @@ static int parseargs(int argc, char *argv[])
 		{"nodeps",     no_argument,       0, 'd'},
 		{"deps",       no_argument,       0, 'd'},
 		{"explicit",   no_argument,       0, 'e'},
-		{"force",      no_argument,       0, 'f'},
 		{"groups",     no_argument,       0, 'g'},
 		{"help",       no_argument,       0, 'h'},
 		{"info",       no_argument,       0, 'i'},
@@ -625,6 +624,7 @@ static int parseargs(int argc, char *argv[])
 		{"config",     required_argument, 0, OP_CONFIG},
 		{"ignore",     required_argument, 0, OP_IGNORE},
 		{"debug",      optional_argument, 0, OP_DEBUG},
+		{"force",      no_argument,       0, OP_FORCE},
 		{"noprogressbar", no_argument,    0, OP_NOPROGRESSBAR},
 		{"noscriptlet", no_argument,      0, OP_NOSCRIPTLET},
 		{"ask",        required_argument, 0, OP_ASK},
-- 
1.7.7



More information about the pacman-dev mailing list