Comment by poincaredisk

Comment by poincaredisk 4 days ago

2 replies

>you don't have to learn any DSLs, unlike bash, zsh, and the like.

I'm not sure I follow. Surely you need to learn PowerShell. What other DSL do you need to learn to use bash?

If you mean, for example, grep syntax: primary use case of a shell is running shell commands, you need to know regex to search using PowerShell too.

I agree that powershell is a better programming language than bash, but I don't really write programs in bash (or fish, which I primarily use). And for serious scripts I prefer Python anyway

>Also, unlike bash, you can use the output of commands like ls directly without worrying that some characters might break your code,

Actually, unlike bash, you can't use the output of arbitrary command. In bash, everything is a text that you can prices generically, grep, less, tail, etc. Unlike in powershell.

stackskipton 4 days ago

Generally other DSLs are other applications you will need with bash to accomplish your goal like grep, curl, jq and others. For example, to hit a rest API, parse the response and then do something based on the response in bash would require curl, jq to properly handle it. Powershell wouldn't require that since Invoke-RestMethod would return dictionary that easily handled. Also, for applications that can return JSON like kubectl, it can easily turn those into objects with ConvertFrom-JSON

Think of Powershell as replacement for bash AND python with built in CLI library. You can run interactively to do little stuff but if you need heavier lifts that requires a script with prompts and all that, you got it.

pwshthrowaway 4 days ago

Nothing stopping you from using PowerShell like that with regular expressions and string manipulations like Select-String, Out-String, -Split.