From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28373 invoked from network); 31 Jul 2021 22:20:08 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 31 Jul 2021 22:20:08 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 4661B9CA5E; Sun, 1 Aug 2021 08:20:07 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 2451B9C9B4; Sun, 1 Aug 2021 08:19:52 +1000 (AEST) Received: by minnie.tuhs.org (Postfix, from userid 112) id DF9A09C9B4; Sun, 1 Aug 2021 08:19:50 +1000 (AEST) Received: from mcvoy.com (mcvoy.com [192.169.23.250]) by minnie.tuhs.org (Postfix) with ESMTPS id 5CA579C9B2 for ; Sun, 1 Aug 2021 08:19:50 +1000 (AEST) Received: by mcvoy.com (Postfix, from userid 3546) id 3C02535E0F8; Sat, 31 Jul 2021 15:19:50 -0700 (PDT) Date: Sat, 31 Jul 2021 15:19:50 -0700 From: Larry McVoy To: Warner Losh Message-ID: <20210731221950.GH23759@mcvoy.com> References: <20210731142533.69caf929@moon> <202107311920.16VJK2jT2362871@fourwinds.com> <202107312132.16VLW6VD2410038@fourwinds.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Subject: Re: [TUHS] Systematic approach to command-line interfaces [ meta issues ] X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: TUHS main list Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" On Sat, Jul 31, 2021 at 04:10:04PM -0600, Warner Losh wrote: > On Sat, Jul 31, 2021 at 3:33 PM Jon Steinhart wrote: > > > Richard Salz writes: > > > On Sat, Jul 31, 2021 at 3:21 PM Jon Steinhart wrote: > > > > > > > opinion, it doesn't add value to do something that's already been done > > > > but differently; it detracts from value because now there's yet another > > > > competing way to do something. > > > > > > > > > > You mean like not using getopt and rolling your own? Shrug. > > > > > > while ((i = getopt(argc, argv, "xxxxx:xxxx")) != -1) > > > switch (i) { > > > case .... > > > } > > > argc -= optind; > > > argv += optind; > > > > > > So I never got getopt(). One of my rules is that I don't use a library > > > > in cases where the number of lines of gunk that that it takes to use a > > > > library function is >= the number of lines to just write it myself. > > > > > > > > > I don't know, what lines in the above are extra beyond what you write? > > The > > > last two if being generous I suppose. > > > > Well, in my opinion that's not really an accurate representation of using > > getopt. > > > > I would of course write the #include line, and the table of options, which > > would > > end up being >= the number of lines that it takes me to do this... > > > > while (--argc > 0) { > > if (*(++argv)[0] == '-') { > > for (p = *argv + 1; *p != '\0'; p++) { > > switch (*p) { > > > > Except for all the things this gets wrong, it's ok. The problem with > inlining getopt > is that you wind up with cases like -f foo'' on the command line being > treated differently > than '-ffoo'. BitKeeper's getopt had a different char for that: "f:" allows -ffoo or -f foo but "f;" insists on no space. With that, I'm bowing out of this thread, it's becoming a bike shed.