And Windows nowadays have like dozen of different security measures that stop you from removing critical system components. It is not like in Windows 95 days, that OS allowed you to remove kernel by just typing a single command.
Comment on More believable for a Linux OS
mox@lemmy.sdf.org 10 months ago
Perfectly safe on Windows, too. The remove() function doesn’t work on directories.
Matriks404@lemmy.world 10 months ago
bhamlin@lemmy.world 10 months ago
And much like Windows, everything dangerous is done better elsewhere.
aodhsishaj@lemmy.world 10 months ago
Remove-Item -LiteralPath "C:" -Force -Recurse
okamiueru@lemmy.world 10 months ago
I’m curious. Does anyone like PowerShell, and the syntax you end up with?
egonallanon@lemm.ee 10 months ago
Yeah I’m a big fan of it. People complain about the verbosity of it but I like that for readability and autocomplete makes that a non issue I find. Plus if you really want to save on typing when using it as a terminal tool you can just make aliases for all your common commands.
okamiueru@lemmy.world 10 months ago
No complaints from me. Maybe if I had to use it. The thing that strikes me as particularly noisy is what seems to be either case insensitive commands and flags, or case sensitive and using Pascal-Case for both commands and flags. Which would be my least preferred option.
AnyOldName3@lemmy.world 10 months ago
Powershell isn’t perfect, but I like it a lot more than anything that takes
sh
as a major influence or thing to maintain backwards compatibility with. I don’t think the Unix philosophy of having lots of small tools that do one thing and do it well that you compose together has ever been achieved as I think being consistent with other tools you use at the same time should be part of doing your thing well, and things like sed, grep and perl all having different regular expression syntax demonstrate inconsistency and are easy to find. I also like that powershell is so verbose as it makes it much easier to read someone else’s script without knowing much powershell, and doesn’t end up getting in the way of actually writing powershell as the autocomplete is really good. I like having a type system and structured data, too.Some of these things are brought to a unixier shell with nushell, but I’m not convinced it’ll take off. Even if people use it, it’ll be a long while before you Google a problem and the solution also includes a nushell snippet, whereas for any Windows problem, you’ll typically get a GUI solution and a powershell solution, and only a maniac would give a CMD solution.
okamiueru@lemmy.world 10 months ago
Why do you think this might be the case? It’s not remotely accurate, which suggests that you must understand it very differently than I do. To some extent, I am curious.
I’ll give you a recent example. Which is just from yesterday. I had a use case where some program had a memory leak, which would eventually lead to the system running out. So, I “built a program that would monitor this and kill the process that used the most memory”. I don’t know how complicated this is in windows and PS, but it took about 2 minutes in Linux, and it very much leverages the Unix philosophy.
Looks something like this:
Each of those pipes do their thing well. The PID of the process using the most memory you can get with something like:
ps aux --sort=-%mem | head -n2 | tail -n1 | awk '{print $2}
Again, using the same Unix philosophy. You then check if the available memory is below some threshold, and send a kill signal to the process if it does. Instead of adding an infinite loop in the script, you stop at making it do that one thing. That is, 1. check remaining memory. 2. if lower than X, kill PID". Let’s call this “foo.sh”. So you end up with is just:
watch -n 2 – ./foo.sh
, and there you go. Every two seconds, it checks available free memory, and saves my system from freezing up.If memory serves me correctly, PS also supports piping, so I would assume you could do similar things. Would be weird not to, given how powerful it is.
OfficerBribe@lemm.ee 10 months ago
I work pretty frequently with PS and have no issues with syntax. It’s easy to read and you always have autocomplete so there is just 1 extra click to get from -r to -Recurse. Same command could be also written as this due to alias feature.
It’s just not the best practice since in PowerShell it is recommended to not use aliases for readability reasons. Also less chance to mess things up due to how verbose all commands and their parameters are.
okamiueru@lemmy.world 10 months ago
Thanks for the info! Is a correct assumption that this is a “yes”, to my question?