by skrebbel · 3y ago · 0 comments
Terrible Get-Finger-Twister -Recurse -Awfully commands, quirky aliases (you can type “curl” but it takes none of curl’s parameters because it’s an alias for Get-WebRequest-Annoyingly or whatever they called it), simple scripting things such as “include file relative to current script” (and not relative to current working directory), etc etc: anything that should’ve been simple and easy was neither.
I’ve stopped paying attention, so maybe they fixed this since then but it really wasn't a very well done system during its first decade or so.
Want to get an organisational unit from Active Directory? Turns out the command is Get-AdOrganizationalUnit. Discoverability is built in. All of the switches are the same. Is it -R or -r for recurse on the Unix command to list OUs from LDAP? What is the command name, anyway? I dunno, but I know the flag I need is -Recurse on Powershell.
Want to dump your DNS zones? Get-DnsServerZone is too verbose, obviously, so “cd /var/named/data && grep '\\(. *A *[0-9][0-9]*\\)\\|\\(..*CNAME..*\\)' db.*” is a much better option (‘scuse the escaping on that regex). Glad we could avoid the long command names.
Born of experience, maybe. Don’t know what the command might be? Get-Command dnszone* saves the day. I suppose I could ask GPT-4 for the regex for the bind dbs, otherwise. These are all things I can teach juniors in about fifteen minutes flat. You don’t need to learn three different Turing complete languages, all of which overload the same set of flags with different operations, just to run an operation against a bunch of files. Familiar, shorthand, and obtuse is not better just because it’s familiar.
rm -rf in powershell:
Remove-Item --Recurse
But it gets better! (worse):
https://learn.microsoft.com/en-us/powershell/module/microsof...
>> Indicates that this cmdlet deletes the items in the specified locations and in all child items of the locations.
>> The Recurse parameter might not delete all subfolders or all child items. This is a known issue.
The awful text manipulation in posix shells feels wrong on a lot of levels, but when you're just trying to accomplish something quickly the "just manipulate strings, always" api is faster to actually work with interactively.
Powershell ends up in this weird space where it's clearly better for writing actual code, but the act of using it to do small interactive things is needlessly difficult.
This is why posix shells stick around I guess - they suck as programming "languages" but they're good enough to do the job, yet they're just really fast to use interactively.
There is a massive gulf between Bash and Powershell -- they're opposite ends of the spectrum -- and it's entirely possible to have something that cherry picks the convenience of Bash with the power of Powershell. Albeit compromises would still have to be made.
There's quite a few alt shells these days now though. So other developers have clearly had the same thought as myself.
"Tooling" is a design smell. It's building hacks on hacks to make bad design and lack of understanding somewhat manageable.
For better systems all you need is a shell and a text editor.
That said, we do need a better shell. But definitely one with UNIX and CLI mentality.
Doesn't make "tooling" any less smelly though.
Unfortunely taken away due to UNIX's free beer offerings.
If Microsoft intends PowerShell to be combined with IDE-like features then they sure have a funny way of showing it.
Since when do bash/zsh offer a full sane programming language, not relying in external executables, a full blown language framework ecosystem, ability to load shared objects and importing public symbols as functions, and interoperate with D-BUS (as COM counterpart) as if client bindings were functions (again withouht external processes)?
Could be, but that wasn't the argument. The argument was, that fish has nice auto-completion, and that could be done without $irrelevant_feature_list.
(Also, by the same token, Powershell isn't Windows.)
> stating that Powershell just mimics existing popular bash/zsh means your not aware of Powershell capabilities versus bash/zsh.
So what does it better than bash/zsh in the area of code completion? Simple tab completion? For history, Ctrl-R and F7? Woo-hoo.
> Since when do bash/zsh offer a full sane programming language, not relying in external executables, (...)
Which is completely irrelevant when we are discussing code completion.
And we’re probably not getting there if people insist on cryptic shortcuts instead of semantic naming, just because they’re inclined to type everything out manually. It’s like those developers writing their code in Notepad++ and pretend that’s the way.
For example `iwr` for Invoke-Web-Request.
Also the full names are only expected to be used in scripts to maintain readability. No one types that in the console. Also ALL Parameters can be abbreviated if they are unique. If no other Parameter starts with R then -R is enough for -Recurse. (there are some quirks with this, but generally pretty intuitive)
And using select or for-each on actual types is magical, instead of grepping/shedding/parsing a maybe standardized string, with completely unsensical names (like grep or sed)
If you give bash and pwsh the same time and love, they will become both pretty ergonomic
So, adding a new parameter starting with R to any command is a breaking change that will crash every script using it? Sounds like a terrible idea.
In a script, write it out in full. When manually typing it’s okay to take shortcuts. There is always a tension between ergonomics and safety.
man grep | grep -- --recursive
-r, --recursiveThey can also be abbreviated if they aren't unique, Powershell will just choose one for you. As an example:
> Get-Content $file -r
Will give you the error "Missing an argument for parameter 'ReadCount'", even though -Raw doesn't take a parameter.Even if you set the colors, there's error/confirm messages that are Bold or ordinary yellow on white.