Found while doing forensics on some rediscovered loose flash drives.

You are viewing a single thread.
View all comments View context
6 points

Text Based OS > Object Based OS

Everything that is wrong with PowerShell in my opinion is driven by the Object Oriented nature of Windows as an OS.

Since everything in Linux is text, grep is king.

permalink
report
parent
reply
21 points

Don’t you think immediately getting the property you’re interested in from an object is easier and more readable than first grepping some output to get the line you want and then removing the leading and trailing garbage on that line manually?

I thing PS scripting would be much more fun if the words weren’t so annoyingly long.

permalink
report
parent
reply
6 points

first grepping some output to get the line you want and then removing the leading and trailing garbage on that line manually

That’s not what we do, though. Give me a more concrete example, and I’ll let you know how I would expect to do it in a nix environment. I’d be curious to compare. Since I have zero experience with powershell, I am not really sure what to expect. The couple times I’ve glanced at a powershell script it looked awful, but I could be falling into Paul Graham’s blub paradox there. OK, I don’t think so, but maybe.

permalink
report
parent
reply
1 point

For instance: Get the temperature of the “Composite” sensor from this output:

$ sensors
k10temp-pci-00c3
Adapter: PCI adapter
Tctl:         +37.1°C  

BAT1-acpi-0
Adapter: ACPI interface
in0:          16.07 V  
curr1:         1.80 A  

amdgpu-pci-0500
Adapter: PCI adapter
vddgfx:        1.46 V  
vddnb:       918.00 mV 
edge:         +35.0°C  
slowPPT:     1000.00 uW 

nvme-pci-0200
Adapter: PCI adapter
Composite:    +28.9°C  (low  =  -5.2°C, high = +79.8°C)
                       (crit = +84.8°C)

acpitz-acpi-0
Adapter: ACPI interface
temp1:        +37.0°C  (crit = +120.0°C)

Without a cryptic awk incantation that only wizards can understand, that would be:

sensors | grep Composite | grep -Po 'Composite:.*?C' | grep -Eo '[[:digit:]]{1,2}\.[[:digit:]]'

permalink
report
parent
reply
16 points

It would be better if they leaned into it. Instead it is object based…. Until it isn’t because then it’s clunky.

permalink
report
parent
reply
7 points

Also lots of command line tools have a flag to output json, and then you can do everything powershell can

permalink
report
parent
reply
6 points

And for those that don’t you have JC

permalink
report
parent
reply

Programmer Humor

!programmerhumor@lemmy.ml

Create post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.

Community stats

  • 6.8K

    Monthly active users

  • 1.4K

    Posts

  • 32K

    Comments