Date: 2005-08-27 Initial Package Version: 2.9.6 Origin: Christian Hamar alias krix and Miklos Vajna Description: Fixes three annoying bugs in pacman's option parsing. 1) If the operation requires at least one target, display the operation's help. (eg. pacman -R is not a valid command) 2) If there is an unknown option, after printfing the error message display the operation's help. 3) fprintf an error message to stderr + display help if no operation specified, but would have to. (eg. -h or -V not used) Examples: Invalid options Original Patched -Qx invalid option invalid option + Q's help -A -R only one operation unchanged -R silent -R's help foo slient general help Diffstat: scripts/makepkg | 2 +- src/pacman.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff -Naur pacman-2.9.6.orig/src/pacman.c pacman-2.9.6/src/pacman.c --- pacman-2.9.6.orig/src/pacman.c 2005-08-27 19:48:17.000000000 +0200 +++ pacman-2.9.6/src/pacman.c 2005-08-27 20:41:24.000000000 +0200 @@ -241,6 +241,10 @@ /* load pm_packages cache */ pm_packages = db_loadpkgs(db_local); + /* the operation requires at least one target */ + if (list_count(pm_targets) == 0 && !(pmo_op == PM_QUERY || (pmo_op == PM_SYNC && (pmo_s_sync || pmo_s_upgrade || pmo_s_clean || pmo_group || pmo_q_list)))) + usage(pmo_op, (char*)basename(argv[0])); + /* start the requested operation */ switch(pmo_op) { case PM_ADD: ret = pacman_add(db_local, pm_targets, NULL); break; @@ -3636,7 +3640,7 @@ case 'v': pmo_verbose = 1; break; case 'w': pmo_s_downloadonly = 1; break; case 'y': pmo_s_sync = 1; break; - case '?': return(1); + case '?': pmo_help = 1; break; default: return(1); } } @@ -3655,6 +3659,12 @@ return(2); } + if (optind == 1) { + fprintf(stderr, "error: you should specify at least one operation\n"); + usage(pmo_op, (char*)basename(argv[0])); + return(2); + } + while(optind < argc) { /* add the target to our target array */ char *s = strdup(argv[optind]); diff -Naur pacman-2.9.6.orig/scripts/makepkg pacman-2.9.6/scripts/makepkg --- pacman-2.9.6.orig/scripts/makepkg 2005-08-28 19:28:42.000000000 +0200 +++ pacman-2.9.6/scripts/makepkg 2005-08-28 19:33:14.000000000 +0200 @@ -1147,7 +1147,7 @@ rm -rf src pkg filelist fi -if [ "$RMDEPS" = "1" -a "`id -u`" = "0" -a "$INFAKEROOT" != "1" ]; then +if [ "$RMDEPS" = "1" -a "`id -u`" = "0" -a "$INFAKEROOT" != "1" -a \( ! -z "$deplist" -o ! -z "$makedeplist" \) ]; then msg "Removing installed dependencies..." pacman -R $makedeplist $deplist