From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,WEIRD_QUOTING autolearn=ham autolearn_force=no version=3.4.2 Received: from minnie.tuhs.org (minnie.tuhs.org [45.79.103.53]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 92a190c5 for ; Sun, 9 Feb 2020 00:19:45 +0000 (UTC) Received: by minnie.tuhs.org (Postfix, from userid 112) id 6A5A19CCAE; Sun, 9 Feb 2020 10:19:43 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id C77EF9CCAD; Sun, 9 Feb 2020 10:19:32 +1000 (AEST) Received: by minnie.tuhs.org (Postfix, from userid 112) id 136819CCAD; Sun, 9 Feb 2020 10:19:31 +1000 (AEST) Received: from mcvoy.com (mcvoy.com [192.169.23.250]) by minnie.tuhs.org (Postfix) with ESMTPS id AB8E69CCA9 for ; Sun, 9 Feb 2020 10:19:30 +1000 (AEST) Received: by mcvoy.com (Postfix, from userid 3546) id 3740835E104; Sat, 8 Feb 2020 16:19:30 -0800 (PST) Date: Sat, 8 Feb 2020 16:19:30 -0800 From: Larry McVoy To: Rob Pike Message-ID: <20200209001930.GF21264@mcvoy.com> References: <46c41c18-5b44-14e5-1f0a-9272866993da@case.edu> <62548c3e-4692-c2d3-f06f-745353490b95@case.edu> 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] Warner's Early Unix Presentation 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: The Eunuchs Hysterical Society Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" > In today's Unix (I use the term loosely) world, the phrase "free of > decoration" is apostasy. Yeah, it's annoying. When I was building my last big system (BitKeeper) I "solved" the problem by having -s (silent) as an option to pretty much every command that produced output. In terms of controlling output, we took the SCCS keywords on steriods, we evolved it to sort of a little programming language. I was told that "bk changes" (think git log sort of) couldn't be taught to produce JSON output. Oh, it can't huh. Below is the input that tells it to do just that. It's sort of awk like, control words are $word, "quoted stuff is printed, :THING: means print whatever THING is, variables are $0 .. $9 and eval to "" or 0 in numerical context. The main body script, much like awk calls it on each line, the script is called on each commit (and it optionally recurses into files as well). I'm pretty proud of it, it works really, really well. $ cat `bk bin`/dspec-changes-json # dspec-v2 # The default dspec used by 'bk changes -json' $begin { "[\n" } $if (:CHANGESET: && !:COMPONENT_V:) { $if($0 -eq 1) { "\},\n" } "\{\n" " \"key\": \":MD5KEY:\",\n" " \"user\": \":USER:\",\n" " \"host\": \":HOST:\",\n" " \"date\": \":Dy:-:Dm:-:Dd:T:T::TZ:\",\n" " \"serial\": :DS:,\n" " \"comments\": \"" $each(:C:){$json{(:C:)}\\n} "\",\n" $if (:TAGS:) { " \"tags\": [ " $each(:TAGS:){:JOIN:"\""(:TAGS:)"\""} " ],\n" } " \"parents\": [ " $if(:PARENT:){"\"" :MD5KEY|PARENT: "\""} $if(:PARENT: && :MPARENT:){," "} $if(:MPARENT:){"\"" :MD5KEY|MPARENT: "\""} " ]\n" ${0=1} # we need to close off the changeset } $end { $if($0 -eq 1) { "\}\n" } "]\n" }