Computer Old Farts Forum
 help / color / mirror / Atom feed
* [COFF] Powershell better than Bourne shell?
@ 2021-11-18 23:03 Greg 'groggy' Lehey
  2021-11-19  1:12 ` Grant Taylor via COFF
  2021-11-19  5:15 ` Adam Thornton
  0 siblings, 2 replies; 7+ messages in thread
From: Greg 'groggy' Lehey @ 2021-11-18 23:03 UTC (permalink / raw)
  To: COFF


[-- Attachment #1.1: Type: text/plain, Size: 603 bytes --]

I recently had a discussion with some colleagues on the topic of
shells.  Two people whom I respect both told me that Microsoft's
Powershell runs rings round the Bourne shell.

Somehow that sounds like anathema to me, but it's not beyond the
bounds of possibility.  Before I waste time investigating, can anybody
here give me some insights?

Greg
--
Sent from my desktop computer.
Finger grog@lemis.com for PGP public key.
See complete headers for address and phone numbers.
This message is digitally signed.  If your Microsoft mail program
reports problems, please read http://lemis.com/broken-MUA.php

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 163 bytes --]

[-- Attachment #2: Type: text/plain, Size: 141 bytes --]

_______________________________________________
COFF mailing list
COFF@minnie.tuhs.org
https://minnie.tuhs.org/cgi-bin/mailman/listinfo/coff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [COFF] Powershell better than Bourne shell?
  2021-11-18 23:03 [COFF] Powershell better than Bourne shell? Greg 'groggy' Lehey
@ 2021-11-19  1:12 ` Grant Taylor via COFF
  2021-11-19 23:00   ` Theodore Y. Ts'o
  2021-11-19  5:15 ` Adam Thornton
  1 sibling, 1 reply; 7+ messages in thread
From: Grant Taylor via COFF @ 2021-11-19  1:12 UTC (permalink / raw)
  To: coff


[-- Attachment #1.1: Type: text/plain, Size: 1272 bytes --]

On 11/18/21 4:03 PM, Greg 'groggy' Lehey wrote:
> I recently had a discussion with some colleagues on the topic of 
> shells.  Two people whom I respect both told me that Microsoft's 
> Powershell runs rings round the Bourne shell.

I've heard praise of PowerShell from people who are skilled in the 
typical Unix shell.  But I've never heard anything on the order of 
running rings around Bourne shell.

> Somehow that sounds like anathema to me, but it's not beyond the bounds 
> of possibility.  Before I waste time investigating, can anybody here 
> give me some insights?

I would say that PowerShell was designed two or more decades /after/ 
Bourne shell and that a lot was learned in computer since in the 
intervening time.

I've been told that PowerShell and / or the commands run therefrom 
actually pass structural data that is easy to query /if/ you know how to 
do so.  It's this structure vs free form textual output that is common 
in Unix shells that make the biggest difference.  Think XML markup vs an 
unstructured text file.  (Though you don't actually see the structure 
scaffolding.)

At least that's my understanding from people competent in traditional 
Unix shells and PowerShell.



-- 
Grant. . . .
unix || die


[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4017 bytes --]

[-- Attachment #2: Type: text/plain, Size: 141 bytes --]

_______________________________________________
COFF mailing list
COFF@minnie.tuhs.org
https://minnie.tuhs.org/cgi-bin/mailman/listinfo/coff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [COFF] Powershell better than Bourne shell?
  2021-11-18 23:03 [COFF] Powershell better than Bourne shell? Greg 'groggy' Lehey
  2021-11-19  1:12 ` Grant Taylor via COFF
@ 2021-11-19  5:15 ` Adam Thornton
  2021-11-19  6:19   ` Andrew Warkentin
  1 sibling, 1 reply; 7+ messages in thread
From: Adam Thornton @ 2021-11-19  5:15 UTC (permalink / raw)
  To: Computer Old Farts Followers, Greg 'groggy' Lehey


[-- Attachment #1.1: Type: text/plain, Size: 1399 bytes --]

It’s not an insane claim.

PS is way wordier but it does deal with structured objects rather than just
byte streams.

I think of PS as being a closer match to VM/CMS Pipelines (but much less
elegant).

There are arguments to be made both ways.  I generally prefer the byte
stream where the producer and consumer have to agree on the format, but,
well, Unix is my homeland.

I guess I argue that PS minus IPC is COBOL to Bourne Shell’s C.  Some
people prefer it and de gustibus non est disputandum.

On Thu, Nov 18, 2021 at 4:12 PM Greg 'groggy' Lehey <grog@lemis.com> wrote:

> I recently had a discussion with some colleagues on the topic of
> shells.  Two people whom I respect both told me that Microsoft's
> Powershell runs rings round the Bourne shell.
>
> Somehow that sounds like anathema to me, but it's not beyond the
> bounds of possibility.  Before I waste time investigating, can anybody
> here give me some insights?
>
> Greg
> --
> Sent from my desktop computer.
> Finger grog@lemis.com for PGP public key.
> See complete headers for address and phone numbers.
> This message is digitally signed.  If your Microsoft mail program
> reports problems, please read http://lemis.com/broken-MUA.php
> _______________________________________________
> COFF mailing list
> COFF@minnie.tuhs.org
> https://minnie.tuhs.org/cgi-bin/mailman/listinfo/coff
>

[-- Attachment #1.2: Type: text/html, Size: 2181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 141 bytes --]

_______________________________________________
COFF mailing list
COFF@minnie.tuhs.org
https://minnie.tuhs.org/cgi-bin/mailman/listinfo/coff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [COFF] Powershell better than Bourne shell?
  2021-11-19  5:15 ` Adam Thornton
@ 2021-11-19  6:19   ` Andrew Warkentin
  2021-11-19 18:44     ` Steffen Nurpmeso
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Warkentin @ 2021-11-19  6:19 UTC (permalink / raw)
  To: coff

(mistakenly sent this as a private message and not to the list)

On 11/18/21, Adam Thornton <athornton@gmail.com> wrote:
> It’s not an insane claim.
>
> PS is way wordier but it does deal with structured objects rather than just
> byte streams.
>
> I think of PS as being a closer match to VM/CMS Pipelines (but much less
> elegant).
>
> There are arguments to be made both ways.  I generally prefer the byte
> stream where the producer and consumer have to agree on the format, but,
> well, Unix is my homeland.
>
> I guess I argue that PS minus IPC is COBOL to Bourne Shell’s C.  Some
> people prefer it and de gustibus non est disputandum.
>

The biggest issue I have with PowerShell besides its verbosity is that
commands have to be implemented as plugins rather than as external
programs.

I'm thinking at some point I may write a Bourne-like shell with
object-oriented features for the OS that I'm working on. Instead of
requiring commands to be plugins to use the object-oriented features I
am thinking of having a generic facility for serialization and
deserialization with hooks to deal with the output format of different
commands (with JSON being an option as well).
_______________________________________________
COFF mailing list
COFF@minnie.tuhs.org
https://minnie.tuhs.org/cgi-bin/mailman/listinfo/coff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [COFF] Powershell better than Bourne shell?
  2021-11-19  6:19   ` Andrew Warkentin
@ 2021-11-19 18:44     ` Steffen Nurpmeso
  0 siblings, 0 replies; 7+ messages in thread
From: Steffen Nurpmeso @ 2021-11-19 18:44 UTC (permalink / raw)
  To: Andrew Warkentin; +Cc: coff

Andrew Warkentin wrote in
 <CAD-qYGovNTQH-jF4A5bGkCiN55u1e7=8oEhwN=GatqTO+=AVeQ@mail.gmail.com>:
 |On 11/18/21, Adam Thornton <athornton@gmail.com> wrote:
 ...
 |The biggest issue I have with PowerShell besides its verbosity is that
 |commands have to be implemented as plugins rather than as external
 |programs.
 |
 |I'm thinking at some point I may write a Bourne-like shell with
 |object-oriented features for the OS that I'm working on. Instead of
 |requiring commands to be plugins to use the object-oriented features I
 |am thinking of having a generic facility for serialization and
 |deserialization with hooks to deal with the output format of different
 |commands (with JSON being an option as well).

I think by the end of the 80s / beginning of 90s David Korn's
shell did offer things like (object|module|x).subcall, aka method
calls in C++ sense or in ruby sense also module functions iirc.
I think there were even modules for graphical user interfaces that
could be driven by Korn shell, but all that i only saw from
glancing over history, i did not live it.

Ruby was slow compared to Perl 19 years ago.  I wrote "Monty"
things for TCL, Python, Ruby, Perl, and object based "Monty" for
the same except TCL.  AMD Athlon 1600+, 133FSB, 256MB (27MB
used;), linux console, 10000 loops:

  monty.php:# ~0.250 secs.
  monty.pl:# ~0.100 secs.
  monty.py:# ~0.590 secs.
  monty.rb:# ~0.178 secs.
  monty.tcl:# ~0.360 secs.
  monty_obj.php:# ~0.310 secs.
  monty_obj.pl:# ~0.175 secs.
  monty_obj.py:# ~0.600 secs.
  monty_obj.rb:# ~0.218 secs.

Back in around 2011 someone counted script language startup CPU
cycles, and iirc Python was several times that of Perl.

--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)
_______________________________________________
COFF mailing list
COFF@minnie.tuhs.org
https://minnie.tuhs.org/cgi-bin/mailman/listinfo/coff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [COFF] Powershell better than Bourne shell?
  2021-11-19  1:12 ` Grant Taylor via COFF
@ 2021-11-19 23:00   ` Theodore Y. Ts'o
  2021-11-20 15:54     ` Michael Kjörling
  0 siblings, 1 reply; 7+ messages in thread
From: Theodore Y. Ts'o @ 2021-11-19 23:00 UTC (permalink / raw)
  To: Grant Taylor; +Cc: coff

On Thu, Nov 18, 2021 at 06:12:12PM -0700, Grant Taylor via COFF wrote:
> I've been told that PowerShell and / or the commands run therefrom actually
> pass structural data that is easy to query /if/ you know how to do so.  It's
> this structure vs free form textual output that is common in Unix shells
> that make the biggest difference.  Think XML markup vs an unstructured text
> file.  (Though you don't actually see the structure scaffolding.)

So I take it you can do something a bit more civilized than this in Powershell?

    run_gcloud compute instances describe --zone "$z" "$i" --format=json > "$inst_info"
    kver=$(jq < "$inst_info" 2> /dev/null
	'.metadata.items[] | select(.key == "kernel_version") | .value' | \
	sed -e 's/^"//' -e 's/"$//' -e 's/^Linux xfstests-[0-9A-Za-z-]* //' \
	-e 's/ .*//')
    gce_status=$(jq < "$inst_info" .status | sed -e 's/^"//' -e 's/"$//')
    status=$(jq < "$inst_info" 2> /dev/null \
        '.metadata.items[] | select(.key == "status") | .value' | \
	sed -e 's/^"//' -e 's/"$//')
    ip=$(jq < "$inst_info" 2> /dev/null \
	'.networkInterfaces[] | .accessConfigs[] | select(.name == "external-nat") | .natIP' | \
        sed -e 's/^"//' -e 's/"$//')
    echo "$i $ip - $kver - $status - $gce_status"

I probably should rewrite the 3500-4000 or so lines of bash script
which is gce-xfstests in Python or Go, but the script has been growing
over the years, and in many ways shell scripting is one of the faster
languages for prototyping new functionality, at least for me, than
Python.  Plus which, bash doesn't do forced march upgrades like Python
does....

					- Ted
_______________________________________________
COFF mailing list
COFF@minnie.tuhs.org
https://minnie.tuhs.org/cgi-bin/mailman/listinfo/coff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [COFF] Powershell better than Bourne shell?
  2021-11-19 23:00   ` Theodore Y. Ts'o
@ 2021-11-20 15:54     ` Michael Kjörling
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Kjörling @ 2021-11-20 15:54 UTC (permalink / raw)
  To: coff

On 19 Nov 2021 18:00 -0500, from tytso@mit.edu (Theodore Y. Ts'o):
>     status=$(jq < "$inst_info" 2> /dev/null \
>         '.metadata.items[] | select(.key == "status") | .value' | \
> 	sed -e 's/^"//' -e 's/"$//')

That's likely a UUOS; Useless Use Of Sed. Try with `jq -r` instead.

(Spotted it because I found myself doing the exact same thing not long
ago. I guess that means I'm in good company.)

-- 
Michael Kjörling • https://michael.kjorling.se • michael@kjorling.se
 “Remember when, on the Internet, nobody cared that you were a dog?”

_______________________________________________
COFF mailing list
COFF@minnie.tuhs.org
https://minnie.tuhs.org/cgi-bin/mailman/listinfo/coff

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-11-20 16:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-18 23:03 [COFF] Powershell better than Bourne shell? Greg 'groggy' Lehey
2021-11-19  1:12 ` Grant Taylor via COFF
2021-11-19 23:00   ` Theodore Y. Ts'o
2021-11-20 15:54     ` Michael Kjörling
2021-11-19  5:15 ` Adam Thornton
2021-11-19  6:19   ` Andrew Warkentin
2021-11-19 18:44     ` Steffen Nurpmeso

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).