7 ms·
What would be a good reason to have POSIX standards in PowerShell, aside from, that's what POSIX does?
by lordgroff 6y ago
What would be a good reason to have POSIX standards in PowerShell, aside from, that's what POSIX does?
- freeone3000 6y agoIt'd make the typing simpler. PowerShell has posix-like aliases, like 'rm' and 'cd', but they don't accept POSIX parameters. So you end up with "rm -Recurse", since rm is an alias for Remove-ChildItem.
- xxpor 6y agoI like PS in theory but the syntax and naming just absolutely kill me. What were they smoking when they named as simple an operation as delete "Remove-ChildItem"? And what's with all of the capital letters? That's what happens I guess when the people designing it haven't actually used a CLI day to day much, because, well, they're using Windows.
- GSGBen 6y agoIt makes a little more sense in context to me. The verbose Verb-Nounish works because the verbs are designed to be limited. E.g. there's Remove- but no Delete- in the standard (shown in `Get-Verb`). So you can then press ctrl+space after typing Remove- and see all the different types of things you can remove. Too many, so you can filter to Remove-<prefix>* etc. The verbosity of cmdlet names when using it as a shell is mitigated with the aliases (e.g rm), and the parameters by accepting any case and shortening to anything non-ambiguous (e.g. `rm -rec -fo`). I guess the capitalisation comes from C# or .net's casing? I like PascalCase for it's great readability/conciseness tradeoff over others, and it's standard windows case-insensitive so I've never had a huge issue with it.
- freeone3000 6y agoThe tradeoff is that "all the things I can remove" is usually "the set of all things my shell knows about" and not "the set of things related to my task at the moment" -- ChildItem-* would be more helpful!
- ziml77 6y agoNeat thing you can do is type "*-Noun" and the tab completion will give you options that fill in the "*". Alternatively "Get-Command *-Noun" will also list out all of the matching commands. Get-Help also supports that kind of wildcard so you get the list of commands along with their help summary. The "*" can even be in the middle. I open VS solution files all the time from Powershell. Since there are often many other files and folders with similar names alongside them I just type ".\*.sln" and hit tab.
- lordgroff 6y agoI can't agree. I have used Linux shells for some time (since 97), and while the olden days would be me laughing at vbs and all that awfulness, I'd take PowerShell any day. The short terse commands and the really awkward, confusing, mistake prone syntax of sh or bash really reels their ugly head in scripts. Interactive shell? No problem. But that's the beauty of PowerShell: verbosity and correctness in scripts, where the IDE quickly expands those long commands, and short aliases for interactive use.
- xxpor 6y agoYeah I agree with that. Bash (and friends) scripts are awful. PS scripts are nice and readable, and not subject to the insane quirks of bash ([ vs [[ vs test? come on) Seems like the real solution is separating scripts from interactive use.
- GoblinSlayer 6y agoIronically it already happened: bash for user interface, but /bin/sh is something else. But bash for user interface keeps being a repl that was accidentally promoted to user interface.
- citrin_ru 6y ago> The short terse commands and the really awkward, confusing, mistake prone syntax When used in an interactive shell short commands save time and effort. And it is easy to learn and remember them because in everyday work you need only about 10 commands. For some some commands which I use a lot I have one-two letter aliases to type even less e. g. i=fgrep. It makes shell scripts less readable for someone who come from windows and and don't know even common shell commands, but for someone who use shell at least from time to time it should be easy to read.
- Poiesis 6y agoI disagree and agree with the sentiment. As someone more familiar with Linux, I sure would prefer to be able to assume a similar style. But the biggest thing I'm happy about WRT Powershell is that it's consistent (and pretty well documented). At least it makes sense. Batch scripting really didn't.
- mseepgood 6y ago> What were they smoking when they named as simple an operation as delete "Remove-ChildItem"? The long names are the official readable names for scripting. It can and does have short aliases like "rm" that you would use in interactive mode. > And what's with all of the capital letters? PowerShell is case-insensitive. The capital letters are for readability.
- TeMPOraL 6y ago> What were they smoking when they named as simple an operation as delete "Remove-ChildItem"? Simple. All these commands work with providers, of which a file system is just one. Other providers include Windows Registry, environment variables, certificate stores, functions and variables in PowerShell runtime. More providers can also be created and plugged into the system. PowerShell Providers are essentially Window's FUSE. See [0] for details. So, for instance, you can do `Get-ChildItem HKCU:` to list entries under HKEY_CURRENT_USER in the Registry, the same way `Get-ChildItem C:/` will list you top-level items on the C: drive. Worth observing: while the console output for these two commands is similar, the results are in fact different objects underneath (Microsoft.Win32.RegistryKey vs. System.IO.FileInfo). In short, these commands are an abstraction over file-system-like things. Whether or not that was a good idea is a different question. -- [0] - https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-psprovider?view=powershell-7.1 https://docs.microsoft.com/en-us/powershell/module/microsoft...
- Pxtl 6y agoJust annoyingly inconsistent when calling PowerShell commandlet vs local exes.