6 ms·
Windows fanboy here. Powershell made the mistake of combining a bad command prompt with a bad scripting language. It is not a "shell" at all. It is bad Python.
by tacos 11y ago
Windows fanboy here. Powershell made the mistake of combining a bad command prompt with a bad scripting language. It is not a "shell" at all. It is bad Python.
The excessive verbosity and object safety is great for admin scenarios where you don't suddenly destroy your corporate email transition because of a VP with an apostrophe in her name. But at that point perhaps you should just use C# instead?
But for everything else it just looks nuts to outsiders. That's why even the MS developer groups are releasing command line tools cross-platform that behave like Unix apps, not PS monstrosities.
https://azure.microsoft.com/en-us/documentation/articles/xplat-cli-install/ https://azure.microsoft.com/en-us/documentation/articles/xpl...
Powershell should be a feature that draws people from AWS. Instead it is seen as a drawback, even inside MS.
- UK-AL 11y agoSimply stating something is bad, without anything to back it up, doesn't make it bad. Learn some alias's if you don't like the Get-X style of functions. gal * | more Will list tons of alias's for you.
- tacos 11y agoGot a directory full of files with underscores in the names? Want spaces instead? Easy, type this: dir -recurse | where {-Not $_.PsIscontainer -AND $_.name -match "_"} | foreach { $New=$_.name.Replace("_"," ") Rename-Item -path $_.Fullname -newname $New -passthru } EDIT: I purposely posted the first Google result. You obviously Googled as well as your code got it backward. But really, why isn't it this? It's worked since the 1980s. You'll dig it since it uses extra apostrophes. rename '_' ' ' *
- UK-AL 11y agoDir | rni –NewName { $_.name –replace " ","_" } That command does some extra stuff, which would make the bash equivalent also complicated.
- latkin 11y agoYep. Technically the request included recursive rename, and to avoid renaming directories, but gosh that's not hard: dir -rec -file | rni –newname { $_.name –replace "_"," " } Edit: Oops, request did not include recursive, the original sample solution did. FWIW top Google results for "unix recursively rename files" give below solutions (slightly different scenarios but you get the idea). Not particularly shorter, or less cryptic: find . -iname "*dbg*" -exec rename _dbg.txt .txt '{}' \; shopt -s globstar nullglob rename _dbg.txt .txt **/*dbg*
- tacos 11y agoY'all are still missing the point. We live in a world where people use CoffeeScript to avoid typing a semicolon. When you Google a PowerShell problem the Google results come back looking insane. You can play code golf here all you want but even this version looks nuts to outsiders. It's a cultural problem. You don't solve it by shouting subtly-differing versions of your culture, louder.
- UK-AL 11y agoHis 'rename' wasn't recursive. <Quote>Y'all are still missing the point. We live in a world where people use CoffeeScript to avoid typing a semicolon. When you Google a PowerShell problem the Google results come back looking insane. You can play code golf here all you want but even this version looks nuts to outsiders It's a cultural problem. You don't solve it by shouting subtly-differing versions of your culture, louder. ".</Quote> You're not getting the point. Powershell is just short, and sometimes shorter if you actually learn it. "When you Google a PowerShell problem the Google results come back looking insane" - This is a problem with the age of powershell. Bash has been around for ever, so there is lots of good quality content on the web.
- tacos 11y agoThat wasn't what I Googled. And Microsoft is announcing bash and Linux shell subsystems today for Windows so y'all are really missing the point. Maybe dev goes one way and ops goes another. But probably not. I'm not betting on Powershell.
- UK-AL 11y ago"You obviously Googled as well as your code got it backward. " - No, just a simple mistake from writing it on the fly. This isn't even probably the smallest, somebody smarter than me could do better. There's probably a PowerShell module that has your equivalent.
- maxxxxx 11y agoIn my view they should have made Powershell as a language that's derived from C#. Or they should have stuck to bash. Both approaches could have worked. Instead it's that weird thing in the middle that doesn't do anything really right.