git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

uses both shell and python codes in one script.


On 2019-10-04 09:15:41 +1000, Chris Angelico wrote:
> On Fri, Oct 4, 2019 at 9:08 AM Cameron Simpson <cs at cskk.id.au> wrote:
> > On 03Oct2019 23:55, Chris Angelico <rosuav at gmail.com> wrote:
> > >In the shell, the first two are an empty string, then ':' is a
> > >colon, which introduces a label (the fact that it's in quotes is
> > >irrelevant to the shell). So there's an empty label followed by a
> > >shell comment.
> >
> > No. ":" is a synonym for "true". (Like "[" is a synonym for "test".)
> >
> > There aren't labels in the shell. This is just a dummy "true" command,
> > with a comment.
> 
> My bad. I remember using a leading colon-space as a multi-shell
> comment, and in at least some of them, it's a label

You may actually be onto something here. I came across this interesting[1]
paper:
http://doc.cat-v.org/unix/unix-reader/A.Research.UNIX.Reader.complete.pdf
which mentions:

    GOTO, : (v2 pages 37-38)

        Goto manipulated the standard input to give the illusion of a
    programmable shell (Thompson, v2) The associated : command, which
    thanks to ASCII collating sequence boasted the first page in the
    manual, was a big nop.

It doesn't explicitely say what : was used for, but since it was
associated with goto, it was very likely used to mark a label.

The Bourne shell, introduced with v7, doesn't have goto, but retained :
as a no-op.

        hp

[1] To Unix history afficionados.

-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp at hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20191028/1e6f9880/attachment.sig>