From owner-cvs-all Tue Jan 11 18: 2:48 2000 Delivered-To: cvs-all@freebsd.org Received: from shell.futuresouth.com (shell.futuresouth.com [198.78.58.28]) by hub.freebsd.org (Postfix) with ESMTP id 94DB6154AB; Tue, 11 Jan 2000 18:02:37 -0800 (PST) (envelope-from fullermd@futuresouth.com) Received: (from fullermd@localhost) by shell.futuresouth.com (8.9.3/8.9.3) id UAA23577; Tue, 11 Jan 2000 20:02:31 -0600 (CST) Date: Tue, 11 Jan 2000 20:02:31 -0600 From: "Matthew D. Fuller" To: Bill Fumerola Cc: Kris Kennaway , cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG Subject: Re: cvs commit: src/usr.sbin/pkg_install/delete perform.c Message-ID: <20000111200231.C22816@futuresouth.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre3i In-Reply-To: X-OS: FreeBSD Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk On Tue, Jan 11, 2000 at 08:13:13PM -0500, a little birdie told me that Bill Fumerola remarked > On Tue, 11 Jan 2000, Kris Kennaway wrote: > > > > Wasn't there a discussion some time ago about making pkg_delete accept a > > > '/var/db/pkg/package-name-version' argument to allow use of filename > > > completion? Some of those package names are rather convulted and painful > > > to type. Was there ever a 'yes' or 'no' decision on that, or is it just > > > waiting for someone to write patches (yes, maybe I am offering...)? > > > > I'd love this to work :-) > > ... and I would commit patches that do this. :-> OK :) See below .sig. One stumbling point (which accounts for a lot of the complexity) is that when using filename completion, often a '/' will get appended to the end as the file we're completing is a directory, so that much be stripped. And once having done that, it makes sense to allow for an abritrary number of '/'s at the end too. Oh well. The style of these files is a bit painful too, I had to go back and change my tab's to spaces to make the diffs look presentable. Remind me to reformat them all sometime when I feel vindictive ;> I'm not too sure how 'clean' or 'good' these patches are, they're perhaps a bit rough and I do believe we're also mucking around with the value stores in argv. Perhaps another copy into a temporary variable for the mucking... But they seem to work fine for all convolutions I can dream up. I haven't tested pkg_delete, only pkg_info, but the diffs are the same, as was the original code, so it looks kosher to me. Anyway, see diffs below... -- Matthew Fuller (MF4839) | fullermd@over-yonder.net Unix Systems Administrator | fullermd@futuresouth.com Specializing in FreeBSD | http://www.over-yonder.net/ "The only reason I'm burning my candle at both ends, is because I haven't figured out how to light the middle yet" Index: delete/main.c =================================================================== RCS file: /usr/cvs/src/usr.sbin/pkg_install/delete/main.c,v retrieving revision 1.14 diff -u -r1.14 main.c --- main.c 1999/08/28 01:18:01 1.14 +++ main.c 2000/01/12 02:00:25 @@ -41,6 +41,7 @@ { int ch, error; char **pkgs, **start; + char *pkgs_split; pkgs = start = argv; while ((ch = getopt(argc, argv, Options)) != -1) @@ -81,9 +82,29 @@ argv += optind; /* Get all the remaining package names, if any */ - /* Get all the remaining package names, if any */ while (*argv) - *pkgs++ = *argv++; + { + if( (pkgs_split = rindex(*argv, (int) '/')) != NULL ) + { + while( !isalpha(*(pkgs_split+1)) ) + { + *pkgs_split = '\0'; + pkgs_split = rindex(*argv, (int) '/'); + } + if(pkgs_split != NULL) + { + pkgs_split++; + *pkgs = pkgs_split; + pkgs++; + } + } + else + { + *pkgs = *argv; + pkgs++; + } + argv++; + } /* If no packages, yelp */ if (pkgs == start) Index: info/main.c =================================================================== RCS file: /usr/cvs/src/usr.sbin/pkg_install/info/main.c,v retrieving revision 1.20 diff -u -r1.20 main.c --- main.c 2000/01/07 13:25:53 1.20 +++ main.c 2000/01/12 02:00:26 @@ -44,6 +44,7 @@ { int ch; char **pkgs, **start; + char *pkgs_split; pkgs = start = argv; if (argc == 1) { @@ -144,7 +145,28 @@ /* Get all the remaining package names, if any */ while (*argv) - *pkgs++ = *argv++; + { + if( (pkgs_split = rindex(*argv, (int) '/')) != NULL ) + { + while( !isalpha(*(pkgs_split+1)) ) + { + *pkgs_split = '\0'; + pkgs_split = rindex(*argv, (int) '/'); + } + if(pkgs_split != NULL) + { + pkgs_split++; + *pkgs = pkgs_split; + pkgs++; + } + } + else + { + *pkgs = *argv; + pkgs++; + } + argv++; + } /* If no packages, yelp */ if (pkgs == start && !AllInstalled && !CheckPkg) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message