From: Bakul Shah <bakul@iitbombay.org>
To: ron minnich <rminnich@gmail.com>
Cc: TUHS main list <tuhs@tuhs.org>
Subject: [TUHS] Re: A few comments on porting the Bourne shell
Date: Tue, 3 Jan 2023 17:37:28 -0800 [thread overview]
Message-ID: <325DF7E4-37BE-4432-9447-0B392B57DC69@iitbombay.org> (raw)
In-Reply-To: <CAP6exYKCEyycFM4CiaW=7fzk_-8uXdLJ=Xq6UP+sHTjtc=+hmw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 6123 bytes --]
I write shell one liners all the time[1].
Go is just too verbose for scripting. I use it for larger programs but typically these don't start out as shell scripts.
[1] In fact I use find (or zsh's **/*), xargs, grep, sort, uniq, field picking often enough that I wish they were built-in a shell but I haven't figured out a simple syntax for it as yet.
> On Jan 3, 2023, at 3:03 PM, ron minnich <rminnich@gmail.com> wrote:
>
> I apologize for this too long message, but context in this case matters.
>
> tl;dr: I agree with the Go folks: past about 10 lines, write a program. But not everybody will agree, as I learned with u-root. Many people love shell programming. I never have.
>
> u-root is a set of Go programs deployed on a couple million data center systems at many companies, including Google.
>
> u-root originally used a compile-on-demand model: type a command name, if it's not in /ubin, it gets built. This was fast, in early Go, typically 250 ms or so. And, in the early days of Go, the Go toolchain, u-root, and all support source easily fit in a 16M SPI part.
>
> The original scripting language for u-root was Go.
>
> There were two commands for this: script and builtin. script would run Go fragments; builtin would take supplied commands and build a custom shell with those built in. Each took 250ms to run.
>
> script took what we called a 'Go fragment', wrapped it with boiler plate, compiled it, and ran it.
> e.g.
> script fmt.Printf("hi\n")
> would build the program and run that code.
> So you could, e.g,, do math:
> script fmt.Printf("%d\n", 6*7)
>
> It could get complex: to see things about interfaces:
> script 'ifaces, _ := net.Interfaces()
> for _, v := range ifaces {
> addrs, _ := v.Addrs()
> Printf("%v has %v", v, addrs)
> }'
>
> you'd get:
> ip: {1 1500 lo up|loopback} has [127.0.0.1/8 <http://127.0.0.1/8> ::1/128]
> ip: {5 1500 eth0 fa:42:2c:d4:0e:01 up|broadcast} has [172.17.0.2/16 <http://172.17.0.2/16> fe80::f842:2cff:fed4:e01/64]
>
> The second command was called builtin. It did not work as other shells do: it built a new shell for you. So, you type:
> bulitin hi fmt.Printf("hi") there fmt.Printf("there\n")
>
> builtin would convert the Go fragments to functions callable in the u-root shell, build a private name space (on Linux or Plan 9 anyway), rebuild the shell with those new functions, and at that point:
> you type
> hi
> in the shell, and it types
> hi
> back. This was built in to your private shell in your private name space. Once you left the shell, it was gone.
> Again, this process of creating and starting the new shell always took about 250 ms (in Go 1.2 that is).
>
> I learned a lesson: people love their shell scripting languages. Nobody wanted to script with Go. It made me sad, but that's how it Go-es.
>
> ron
> p.s. the 'script' command is still available as an experimental u-root command. Source mode is now independent: github.com/u-root/sourcery <http://github.com/u-root/sourcery>
>
>
> On Tue, Jan 3, 2023 at 2:35 PM Steffen Nurpmeso <steffen@sdaoden.eu <mailto:steffen@sdaoden.eu>> wrote:
>> Steve Nickolas wrote in
>> <alpine.DEB.2.21.2301031307001.9988@sd-119843.dedibox.fr <mailto:alpine.DEB.2.21.2301031307001.9988@sd-119843.dedibox.fr>>:
>> |On Tue, 3 Jan 2023, Dan Cross wrote:
>> |> Something I've noticed is that lots of people try to increase
>> |> complexity to solve problems, and it rarely occurs to them to
>> |> eliminate complexity to solve problems. Sometimes the reasons for this
>> |> are good; most of the time they are not.
>> |>
>> |> - Dan C.
>> |
>> |I think of the saying: "Perfection is not when there is nothing left to
>> |add, but when there is nothing left to remove."
>>
>> He (Exupéry) was then shot down.
>>
>> I always seem to response this to that.
>> Hmm, openpgp@ietf.org <mailto:openpgp@ietf.org> (to which i have almost zero to add
>> technically shall someone think that, nor do i want) lastly
>>
>> |"Perfection is achieved not when there is nothing more to add but when \
>> |there
>> |is nothing left to take away" - Antoine de Saint-Exupéry.
>>
>> He was then shot down.
>>
>> But yes, he then really went missing.
>>
>> The topic ..
>> I do not miss times where suddenly a shell script breaks because
>> ": > FILE" does not work (just recently 'realized from reading code
>> of Paul Eggert of GNU/IANA TZ, "hey, > FILE" is of course
>> sufficient!"), i fixed it via "printf '' > FILE" by then; whatever
>> the reason. May it be bugs or (local) miscompilations, not
>> detected due to missing unit tests and a too small user base.
>>
>> Portable? If i find /usr/xpg4/bin i quickly add it to $PATH for
>> the much better awk (but beware of documented double expansion
>> issues) and the much much better sh(1).
>> Some things just require that, noclobber I/O redirection (set -C)
>> for example. (mktemp(1) is still not part of the POSIX standard.)
>>
>> Besides i miss(ed) the history; the author of bmake (and
>> verieexec) just last year asked me why i would use stty for
>> a purpose ("(<&1 >/dev/null stty -a) 2>/dev/null") instead of
>> simply using "[ -t 1 ]", and indeed, i found that as soon as BSD
>> 4.1 and Research V7, but it surprised me.
>> Without an oversight of the history and the lack of many systems
>> to test, perl(1) was omnipresent and if only for OpenSSL and so
>> using it for almost anything seemed save.
>>
>> To love is not to look at one another: it is to look,
>> together, in the same direction. Antoine de Saint-Exupéry.
>>
>> A happy and healthy new Year 2023 is now overdue.
>> Even Giants have to die, but with holding hands it can wait a bit
>> longer, i hope.
>> I wish that from Germany to all of you, and deliberately beyond
>> NATO readership.
>>
>> --steffen
>> |
>> |Der Kragenbaer, The moon bear,
>> |der holt sich munter he cheerfully and one by one
>> |einen nach dem anderen runter wa.ks himself off
>> |(By Robert Gernhardt)
[-- Attachment #2: Type: text/html, Size: 7625 bytes --]
next prev parent reply other threads:[~2023-01-04 1:38 UTC|newest]
Thread overview: 112+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-03 15:08 Douglas McIlroy
2023-01-03 15:57 ` Alejandro Colomar
2023-01-03 17:19 ` Jon Steinhart
2023-01-05 13:22 ` Tom Ivar Helbekkmo via TUHS
2023-01-05 21:11 ` Rob Pike
2023-01-03 17:26 ` Dan Cross
2023-01-03 18:07 ` Steve Nickolas
2023-01-03 20:19 ` Steffen Nurpmeso
2023-01-03 23:03 ` ron minnich
2023-01-04 1:37 ` Bakul Shah [this message]
2023-01-04 1:58 ` Adam Thornton
2023-01-04 15:19 ` Ralph Corderoy
2023-01-04 18:01 ` Bakul Shah
2023-01-04 20:46 ` Alejandro Colomar
2023-01-05 0:06 ` John Cowan
2023-01-05 0:41 ` Adam Thornton
2023-01-04 5:05 ` Theodore Ts'o
2023-01-03 18:19 ` Niklas Karlsson
2023-01-04 1:29 ` Adam Thornton
2023-01-05 1:51 ` Alejandro Colomar
-- strict thread matches above, loose matches on Subject: below --
2022-12-31 13:26 Douglas McIlroy
2022-12-31 22:19 ` Rob Pike
2022-12-30 18:25 [TUHS] " Paul Ruizendaal
2022-12-30 19:51 ` [TUHS] " Chet Ramey
2022-12-30 20:02 ` Larry McVoy
2022-12-30 20:31 ` Adam Thornton
2022-12-30 20:49 ` Chet Ramey
2022-12-30 20:42 ` Sven Mascheck
2022-12-30 20:48 ` Jon Steinhart
2022-12-30 20:51 ` Sven Mascheck
2022-12-31 11:40 ` Ralph Corderoy
2022-12-31 18:49 ` Jon Steinhart
2022-12-31 19:24 ` Clem Cole
2023-01-03 16:32 ` Chet Ramey
2023-01-01 1:51 ` Ron Natalie
2022-12-30 20:47 ` Chet Ramey
2022-12-31 0:08 ` Luther Johnson
2022-12-31 3:59 ` Larry McVoy
2022-12-31 4:12 ` Steve Nickolas
2022-12-31 4:18 ` Bakul Shah
2022-12-31 4:40 ` Larry McVoy
2022-12-31 4:19 ` Marc Donner
2022-12-31 4:23 ` Dave Horsfall
2022-12-31 4:37 ` Clem Cole
2023-01-02 5:10 ` Mary Ann Horton
2023-01-02 16:25 ` Clem Cole
2023-01-02 16:51 ` Larry McVoy
2023-01-02 17:32 ` Adam Thornton
2023-01-02 17:43 ` Larry McVoy
2023-01-02 17:48 ` Luther Johnson
2023-01-02 18:00 ` G. Branden Robinson
2023-01-02 18:05 ` Luther Johnson
2023-01-02 18:12 ` Larry McVoy
2023-01-02 18:16 ` Clem Cole
2023-01-02 19:50 ` Warner Losh
2023-01-02 20:05 ` Adam Thornton
2023-01-02 19:21 ` G. Branden Robinson
2023-01-02 19:34 ` Rich Salz
2023-01-02 20:12 ` Larry McVoy
2023-01-02 20:24 ` G. Branden Robinson
2023-01-02 20:41 ` Larry McVoy
2023-01-02 21:00 ` Dan Cross
2023-01-02 21:06 ` Clem Cole
2023-01-02 21:19 ` Dan Cross
2023-01-02 22:54 ` segaloco via TUHS
2023-01-02 23:58 ` Jon Steinhart
2023-01-04 9:00 ` Joseph Holsten
2023-01-02 22:43 ` Steve Nickolas
2023-01-02 21:08 ` Joseph Holsten
2023-01-02 21:15 ` Adam Thornton
2023-01-02 17:55 ` Adam Thornton
2023-01-02 18:11 ` Clem Cole
2023-01-02 18:36 ` Dan Cross
2023-01-02 18:48 ` Dan Cross
2023-01-02 18:18 ` Larry McVoy
2023-01-04 3:20 ` John Cowan
2023-01-04 3:31 ` Dan Cross
2023-01-04 4:16 ` Bakul Shah
2023-01-04 16:15 ` Dan Cross
2023-01-04 18:28 ` ron minnich
2023-01-04 19:33 ` Chet Ramey
2023-01-04 15:21 ` Ralph Corderoy
2023-01-04 15:54 ` Ron Natalie
2023-01-02 17:55 ` Clem Cole
2023-01-03 17:08 ` Paul Winalski
2023-01-03 19:19 ` Warner Losh
2023-01-03 19:56 ` Luther Johnson
2023-01-03 20:21 ` Dave Horsfall
2023-01-03 21:47 ` Clem Cole
2023-01-03 21:51 ` Clem Cole
2022-12-31 4:41 ` Greg 'groggy' Lehey
2022-12-30 20:20 ` Sven Mascheck
2022-12-30 20:49 ` Ron Natalie
2022-12-30 20:52 ` Rob Pike
2022-12-30 20:53 ` Jon Steinhart
2023-01-01 10:44 ` arnold
2023-01-01 11:28 ` arnold
2023-01-03 16:34 ` Chet Ramey
2023-01-03 15:06 ` Chet Ramey
2022-12-30 19:57 ` segaloco via TUHS
2022-12-31 12:55 ` Paul Ruizendaal
2023-01-01 2:55 ` Warner Losh
2023-01-01 4:38 ` Jonathan Gray
2023-01-01 5:25 ` Warner Losh
2023-01-01 5:35 ` Dan Cross
2023-01-01 5:52 ` G. Branden Robinson
2023-01-01 6:35 ` Warner Losh
2023-01-01 6:35 ` Rob Pike
2023-01-01 6:27 ` Warner Losh
2023-01-01 14:50 ` Ron Natalie
2023-01-01 7:11 ` Jonathan Gray
2023-01-01 7:21 ` Warner Losh
2023-01-01 10:25 ` Paul Ruizendaal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=325DF7E4-37BE-4432-9447-0B392B57DC69@iitbombay.org \
--to=bakul@iitbombay.org \
--cc=rminnich@gmail.com \
--cc=tuhs@tuhs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).