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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 482 invoked from network); 1 Aug 2021 18:18:19 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 1 Aug 2021 18:18:19 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 06D279CAA3; Mon, 2 Aug 2021 04:18:16 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id 9A8219CA63; Mon, 2 Aug 2021 04:17:58 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=pass (2048-bit key; unprotected) header.d=dartmouth.edu header.i=@dartmouth.edu header.b="Oaa8iT5D"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id C31F29CA63; Mon, 2 Aug 2021 04:17:56 +1000 (AEST) Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by minnie.tuhs.org (Postfix) with ESMTPS id 040099CA60 for ; Mon, 2 Aug 2021 04:17:56 +1000 (AEST) Received: by mail-wr1-f50.google.com with SMTP id m12so13903262wru.12 for ; Sun, 01 Aug 2021 11:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dartmouth.edu; s=google1; h=mime-version:from:date:message-id:subject:to; bh=mOOQyTKoSMvSNP7jVk5Q3J7Irsx8uV1gGyWWGuND/F4=; b=Oaa8iT5Djiv8Puldm3sQOwgNj/1uJ3DsdwPrHqJhyZKHx+0594AZHM8ftynV0VB53d TAVibw0g+U5/27SldZrmtvw96+rp/FvbDwZ5kIa7yC8TDTKuwwsVWlkTkwX8G/vCJP9T m9rEit1pFDSgCrnh4lEc0J3ieETgum9A/1mTiOERUwHS/qxVo7Y+AOkIRWCsfbqna7L8 3nhzmk14Qm1OavE0LMxHtQkPTk5a1PBe4fPeZkuHphYwsboPgPTaCJ0e+OJAMUYFblMc okJU0jQnVGOGeg1kX08XJgOiM4EfE5WRTyAlCqze/Wq3gBAxS5bFr+9v1G1Yh2viWO1q Vk3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=mOOQyTKoSMvSNP7jVk5Q3J7Irsx8uV1gGyWWGuND/F4=; b=QdrCFjqpB/s6SaDotMePXymXi8WCegeq8+5PbrrQ2Mr/L7DK55zgko9IVClRKwlrXD Ktr+N2Mk/7KsG7oVdRIshVqDhuVyokxI6Zwt+VmmTcXpJ+p9sqn/1KXUtT2wU6ISkZ3/ WzYerv4WT3iZK+2RDWq7e4enK8saJMWqepK5wS0OTCrS+J2xH4+ylp+5LdcqYcSB6DQN M91Yu8VllbsO15pVZXD5e7qC59WGL0t+gtVidSRQVQxamRchxP807AlTQnY0Bm4MNugN F/9EchJGK5JCg2/6NAJw48xuVT9P1uTpUB8txvwJWDhMC8JsOFFGhNbNGcoRuPbxrvwi iCQA== X-Gm-Message-State: AOAM533I+RobVd9gsadftmNrmRNe9HRgNs28VoQkQZPM0JQz7Zgihq1I +dKG6/wH3vPFqTLouOR+x3xRp5JkjWZ84X88g3OlRrG01LVVxQ== X-Google-Smtp-Source: ABdhPJwjWNrhhZQ8ApUV/S5knEcJDtfA1zVV3us8ghSyOxiU6Kot9gUQWsU0UoaQQa+rQRUFQXqy2MgzqraNTbTP2SU= X-Received: by 2002:a5d:6d86:: with SMTP id l6mr13895462wrs.260.1627841874145; Sun, 01 Aug 2021 11:17:54 -0700 (PDT) MIME-Version: 1.0 From: Douglas McIlroy Date: Sun, 1 Aug 2021 14:17:39 -0400 Message-ID: To: The Eunuchs Hysterical Society Content-Type: text/plain; charset="UTF-8" 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: , Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" I have considerable sympathy with the general idea of formally specifying and parsing inputs. Langsec people make a strong case for doing so. The white paper,"A systematic approach to modern Unix-like command interfaces", proposes to "simplify parsing by facilitating the creation of easy-to-use 'grammar-based' parsers". I'm not clear on what is meant by "parser". A plain parser is a beast that builds a parse tree according to a grammar. For most standard Unix programs, the parse tree has two kinds of leaves: non-options and options with k parameters. Getopt restricts k to {0,1}. Aside from fiddling with argc and argv, I see little difference in working with a parse tree for arguments that could be handled by getopt and working with using getopt directly. A more general parser could handle more elaborate grammatic constraints on options, for example, field specs in sort(1), requirements on presence of options in tar(1), or representation of multiple parameters in cut(1). In realizing the white paper's desire to "have the parser provide the results to the program", it's likely that the mechanism will, like Yacc, go beyond parsing and invoke semantic actions as it identifies tree nodes. Pioneer Yaccification of some commands might be a worthy demo. Doug