Shells

How is the UNIX shell better exactly?

Attached: PowerShell_icon.png (256x256, 8.07K)

Other urls found in this thread:

stedolan.github.io/jq/manual/)
github.com/TomNomNom/gron
twitter.com/SFWRedditVideos

It's not. It's software design for a 50 year old minicomputer, leaving you with the same limitations of that same computer, only its just faster.

Therein lies the power, but while this is useful in the guts of a non-trivial script, it adds a bit of impedance when used in the midst of an otherwise text-only pipeline. It's not convenient to write adapter boilerplate to serialize and deserialize those objects, which I think is one of several reasons Linux users aren't installing Powershell Core. Also, the real applicability of Powershell lies in:
Unless you're already sipping the .NET cool-aid, Powershell is more of a hindrance than a help. Just use Nim/Python/whatever otherwise.

Don't see the benefit.

Same with bash.

zsh does that.

bash support arrays.

You prefer parsing strings to property accessors?

Bloat. sh is not that bad, it's mostly the surrounding tools that are bad.

My old job required writing powershell scripts, it sucks ass. If they used Linux I could do everything twice as fast but powershell makes everything a pain. Also the autocomplete is shit

Please, explain.

Attached: c92c00f04c4e1c626a24a9b5fb0405408b4a5001_hq.gif (500x281, 721.15K)

Is PowerShell really a shell scripting language?

You do realise you can pipe out objects via Unix pipes right? Just pick a format and write programs that support it. Tons of stuff already passes around JSON, and if you want something lighter you can take advantage of Google's protocol buffers.

When you're piping shell processes which output text to the terminal, you'll often need to filter out unneeded text or use regexp groups to extract the bits you want before passing them to the next pipe. When your shell is piping objects instead of text, you can use property accessors and WHERE clauses to filter the data.

For example, if you wanted to change the CPU allocation of every currently running virtual machine on a Windows hypervisor, you could do it in a single line in Powershell:

Get-VM | Where { $_.State –eq ‘Running’ } | Stop-VM -Force -Passthru | Set-VM -ProcessorCount 4 -Passthru | Start-VM

To do the same thing in Linux with a text-based shell, you'd have to list the VM table (using virsh, qm, or some other VM manager), filter the rows which don't contain RUNNING in the status column using awk or sed, parse those lines for the Virtual Machine IDs, run the virtual machine manager again for each ID to stop them from running, run the virtual machine manager again for each ID to set the CPU count, and run the virtual machine manager yes again for each ID to start them back up.

On my Linux hypervisor, my script which automates these tasks (and uses proper BASH data structures to keep it as D.R.Y. as possible) is about 100 lines of painstakingly well-tested code. I would've saved many hours if Powershell were an option.

As someone who knows PowerShell but no Bash, I feel the opposite way when someone throws a linux box my way at work.

If they just used IIS to host this shit, the script would have been done by now.

loves this gif. thank you user

Definitely see the advantage, but it's always felt like more keystrokes than unix sh/bash/zsh, making it difficult for it to take the place of zsh for me

The extra keystrokes pay off for scripts, though, since you don't leave behind alphabet-soup option strings for the next guy to untangle.

Your shit isn't very modular though, unlike plaintext pipes. The only problem of UNIX (and POSIX tools) is that there isn't a tabular interchange format for all tools; if only they had forbidden tabs and newlines in filenames, TSV could have been used to great avail.

That's a bad thing, though. If you type 'tool-' and use completions, you'll get everything related to tool, but if type 'action-' and complete, you'll just get a bunch of unrelated stuff.

Might be better as a scripting language but it fucking blows as a terminal, granted I never used it for more than a few hours but the commands are long as shit for some reason.

Attached: IMG_20181026_120030.jpg (720x706, 78.52K)

Uhhh it's extremely modular, what are you referring to exactly?

Shells are great. I wrote a basic shell once.
Parsing strings to parse strings to parse strings is just an amazing feeling.

Its concepts are far better. It's a great idea, but the syntax is shit. It's an annoying half-assed compromise between a shell and a scripting language, and you're almost always better off just using a better programming language that is a real programming language to do the same thing, like IronPython or IronRuby or something of the sort.

So Unix shell is better because it does what it's supposed to do, be a user-interactable shell where you can pipe data from anything to anything and it will usually work. You can grep for something without knowing its structure or having to worry about passing into the specifically right program to consume that type of data, as it's all text.

PowerShell is more powerful, but it's not a very good shell or a very good programming language, so it hits an awkward-to-use spot that's not particularly pleasant.

Wow.

nope, sh is bad

It fits a niche though. It's easy enough to learn and powerful enough where you don't need to learn a "real programming language" to become truly effective.

FreeBSD, though fucked in other ways, solved the output parsing problem correctly. You can tell its standard utilities like ls(1) to output machine-readable data in JSON, XML or HTML. It's better than actual opaque objects. jq (stedolan.github.io/jq/manual/) makes processing JSON from the shell a breeze.

Started learning this, and was able to trivialize a lot of server operations... is this the power of Microsoft®?

PowerShill is slow as fuck, it has shitty auto-completion and the naming conventions are counter-intuitive. Also, every time I try to run update-help, it can't finish for whatever reason. I think perl and ruby are better for scripting.

JSON
XML
HTML

user.
Are you running at as admin? Does your admin account have access to the internet? If not you can download the help-files with your internet enabled account, and then update the help files from the locally saved versions with your admin account:
Save-Help -DestinationPath PATHUpdate-Help -SourcePath PATH

WSO is my fav web shell
I usually find a way to upload a web shell and then pivot to a reverse shell using a netcat listener and /dev/tcp/ with bash or sh

or are you just talking about lame local shells?

You described python.

JQ is garbage if you don't know the structure of a json file. json.sh is better than jq for those instances.
gron is better than both
github.com/TomNomNom/gron