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=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 25060 invoked from network); 1 Aug 2021 21:55:10 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 1 Aug 2021 21:55:10 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 55F509CA69; Mon, 2 Aug 2021 07:55:09 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id BC5149CA63; Mon, 2 Aug 2021 07:54:43 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="CVhxPsa/"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id 931F19CA63; Mon, 2 Aug 2021 07:54:37 +1000 (AEST) Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) by minnie.tuhs.org (Postfix) with ESMTPS id 0513B9CA60 for ; Mon, 2 Aug 2021 07:54:37 +1000 (AEST) Received: by mail-ot1-f45.google.com with SMTP id o2-20020a9d22020000b0290462f0ab0800so15735110ota.11 for ; Sun, 01 Aug 2021 14:54:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=utMsoekP874Ap99FF4Mz6YH5wkUuBo76vvv2jqhzxE4=; b=CVhxPsa/Kof/ZZs4oySayKAreCko0azBcVq86RX2IH6UspSfcQYEOY+aXWXa3I6XzD z3bI0hpw5X4PBQP96m3qTAPoVjyB5dAgOVzOgNT2+RCLjVmpiuG10K2Q1a1tRaz6sQJH nFGqzBaxw0hNbTrdKl7zzdrxWkFbzTrq5hvT2vUjFjRj2PDwbN3k8EW+WAseDen0flQo 6Swf1mdB4Nd1OAsoNCqMHxWqAuIHRdjXYWd2C+B5Qe0GAeK8KfABxSyz3py7ZoAfn27v QcUei5FObskebqa/KnfSb/4ZU77R0jDrgLS1bARV5tYddpwCFDwi0q5+18MFs5neyTwm u6+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=utMsoekP874Ap99FF4Mz6YH5wkUuBo76vvv2jqhzxE4=; b=WUcfvO3SWYg7Ideg1rgXDhKoMnFwCw14maTyQTEj4ER2qXoFox7juJEaRwRWoRU6/2 icsVb+jrnC+OEnaWpdam0uEsADvuaTo6wk/VcjilEJHEik9PewjvHpDLiEYATZS5Dsrt 65o0/61ova91heBWZ0Lf9m3232+ER4pB3Tt5/QE+xTXxJgKjeODPeaNdi3cVPMHIV+hU 7PRoKACfrGu3qJHShrek0qCuwVhRGUFDb7GneiZK6P1/h/Ta6fVl6bL7FaB6QKJXJYrQ PBSFnvqOjqTAzpECiQ9gkR3x51C8PqCvyO5IhwvXVmXpVVRucrhHMZCkUvTYGARfc3Cb tN1g== X-Gm-Message-State: AOAM533zMvv+Jyi5jVQBlWTUsCmkiDCn+BVcJloCd0qrnfltykD+uj5Z wOelnULUJ1uYyVzL1kRqVcxHWHTAe2AnZWUAmak= X-Google-Smtp-Source: ABdhPJz9fM6nZbbqpnANTCGl4qMLLtJ/ssOqc9xEJOShFybVqZvghGS9m4SUWRBfRnVH/+LfUNmOyE8O10qIjSeHWcw= X-Received: by 2002:a05:6830:51:: with SMTP id d17mr9447558otp.65.1627854876293; Sun, 01 Aug 2021 14:54:36 -0700 (PDT) MIME-Version: 1.0 References: <20210731142533.69caf929@moon> <40763c2d-52ad-eb01-8bf8-85acf6fee700@case.edu> In-Reply-To: <40763c2d-52ad-eb01-8bf8-85acf6fee700@case.edu> From: Dan Cross Date: Sun, 1 Aug 2021 17:53:59 -0400 Message-ID: To: Chester Ramey Content-Type: multipart/alternative; boundary="000000000000a5bc6005c8867f1e" Subject: Re: [TUHS] Systematic approach to command-line interfaces 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" --000000000000a5bc6005c8867f1e Content-Type: text/plain; charset="UTF-8" On Sun, Aug 1, 2021 at 1:44 PM Chet Ramey wrote: > On 7/31/21 12:19 PM, Dan Cross wrote: > > There was someone posting here on TUHS a while back about leveraging a > > special context-sensitive `--shell-help` or similar command line program > > and synthesizing a protocol between the shell and a program to provide > > TOPS-20 like command completion. It was nowhere near what you get from > the > > COMND JSYS, but seemed like a reasonable approximation. > > This is essentially how the existing shells do it (bash, zsh, tcsh, etc.), > but in an ad-hoc fashion. There is no standard way to obtain possible > completions or list possible arguments, so the shells push that to external > generators. > > Since you have to perform the completion in the shell, there has to be some > way to tell the shell the possible completions for each command of > interest, whether that's options or arguments. The different shells have > solved that in essentially the same way, with a few syntactic variations. > > Bash provides a framework (complete/compgen/compctl) and pushes a lot of > the command-specific work to external completers. It provides access to the > shell internals (lists of builtins, functions, aliases, variables, and so > on) and built-in ways to perform common completions (filenames, directory > names, command names, etc.), and leaves the rest to external commands or > shell functions. > > The real power and flexibility comes from being able to invoke these > external commands or shell functions to generate lists of possible > completions, and defining an API between the shell and those generators to > specify enough of the command line to make it easy to find the word to be > completed, the command for which completion is being attempted, and > clarifying context around that word. In the same way, the shell provides an > API for those generators to return possible completions. > > The knowledge about each command's options and arguments is embedded in > these generators. > > A standard way to handle command line options and arguments would make > generators easier to write, but doesn't address the other issues of what, > exactly, the user wants to complete, so the existing mechanisms would > likely not change very much. Something like `--shell-help', as long as it > were context-sensitive, would help more. Thanks for the useful background information on existing solutions. If I understood the proposal correctly, it was that the program in question would, itself, be the generator as described above. Perhaps it was coupled with a standard structured format for consumption by the shell, which seems like it would be useful for this sort of expansion. Of course, the process model in TOPS-20 was very different than in Unix, and in that system, as soon as you typed the _name_ of a command it's image was "run up" in your process. So the interactive help system was provided by a running instance of the program itself. What I gathered from the proposed model was that it involved multiple invocations of the program, but with a special option that would trigger behavior informally described as, "here's the context I've built so far; let me know what options are available here." I don't know that it's terribly "Unixy", but I can see how it would be useful for interactive use. As an aside, I maintain some older "machines" at home (even modest hardware can emulate a PDP-10 or Honeywell DPS8), and find that doing so provides me with perspective that can be very useful. Looking at other systems that were available roughly around the time of Unix (TENEX, Multics), it strikes me that the Unix was a bit of an odd-duck with the way it handled exec in terms of destructively overlaying the memory of the user portion of a process with a new image; am I wrong here? I wonder why the "one program per process and exec destroys what was running before" mechanism was implemented? I can imagine it had a lot to do with the constraints that early Unix machines must have imposed on design, not to mention implementation simplicity, but I wonder what the designers thought of other systems' process models and whether they were considered at all? Perhaps Doug and Ken might have thoughts here? - Dan C. --000000000000a5bc6005c8867f1e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sun, Aug 1, 2021 at 1:44 PM Chet Ramey= <chet.ramey@case.edu> wro= te:
On 7/31/21 12:19 PM, Dan Cross wrote:
> There was someone posting here on TUHS a while back about leveraging a=
> special context-sensitive `--shell-help` or similar command line progr= am
> and synthesizing a protocol between the shell and a program to provide=
> TOPS-20 like command completion. It was nowhere near what you get from= the
> COMND JSYS, but seemed like a reasonable approximation.

This is essentially how the existing shells do it (bash, zsh, tcsh, etc.),<= br> but in an ad-hoc fashion. There is no standard way to obtain possible
completions or list possible arguments, so the shells push that to external=
generators.

Since you have to perform the completion in the shell, there has to be some=
way to tell the shell the possible completions for each command of
interest, whether that's options or arguments. The different shells hav= e
solved that in essentially the same way, with a few syntactic variations.
Bash provides a framework (complete/compgen/compctl) and pushes a lot of the command-specific work to external completers. It provides access to the=
shell internals (lists of builtins, functions, aliases, variables, and so on) and built-in ways to perform common completions (filenames, directory names, command names, etc.), and leaves the rest to external commands or shell functions.

The real power and flexibility comes from being able to invoke these
external commands or shell functions to generate lists of possible
completions, and defining an API between the shell and those generators to<= br> specify enough of the command line to make it easy to find the word to be completed, the command for which completion is being attempted, and
clarifying context around that word. In the same way, the shell provides an=
API for those generators to return possible completions.

The knowledge about each command's options and arguments is embedded in=
these generators.

A standard way to handle command line options and arguments would make
generators easier to write, but doesn't address the other issues of wha= t,
exactly, the user wants to complete, so the existing mechanisms would
likely not change very much. Something like `--shell-help', as long as = it
were context-sensitive, would help more.

Th= anks for the useful background information on existing solutions.

If I understood the proposal correctly, it was that the pro= gram in question would, itself, be the generator as described above. Perhap= s it was coupled with a standard structured format for consumption by the s= hell, which seems like it would be useful for this sort of expansion.
=

Of course, the process model in TOPS-20 was very differ= ent than in Unix, and in that system, as soon as you typed the _name_ of a = command it's image was "run up" in your process. So the inter= active help system was provided by a running instance of the program itself= . What I gathered from the proposed model was that it involved=C2=A0multipl= e invocations of the program, but with a special option that would trigger = behavior informally described as, "here's the context I've bui= lt so far; let me know what options are available here." I don't k= now that it's terribly "Unixy", but I can see how it would be= useful for interactive use.

As an aside, I mainta= in some older "machines" at home (even modest hardware can emulat= e a PDP-10 or Honeywell DPS8), and find that doing so provides me with pers= pective that can be very useful. Looking at=C2=A0other systems that were av= ailable roughly around the time of Unix (TENEX, Multics), it strikes me tha= t the Unix was a bit of an odd-duck with the way it handled exec in terms o= f destructively overlaying the memory of the user portion of a process with= a new image; am I wrong here? I wonder why the "one program per proce= ss and exec destroys what was running before" mechanism was implemente= d? I can imagine it had a lot to do with the constraints that early Unix ma= chines must have imposed on design, not to mention implementation simplicit= y, but I wonder what the designers thought of other systems' process mo= dels and whether they were considered at all? Perhaps Doug and Ken might ha= ve thoughts here?

=C2=A0 =C2=A0 =C2=A0 =C2=A0 - Da= n C.

--000000000000a5bc6005c8867f1e--