3 ms·
PowerShell obeys the first iron law of I/O: ALL data has a type. Bash (and Unix in general) -- does not. Now of course the implementation of typed pipelines in
by bitwize 11y ago
PowerShell obeys the first iron law of I/O: ALL data has a type. Bash (and Unix in general) -- does not.
Now of course the implementation of typed pipelines in PowerShell is clunky and forced, because typed I/O primitives do not (yet) actually exist in Windows, so all the piping is done within one process with streams of object pointers, else it doesn't work. There are other problems, too: I recall one advocate linking me to the PowerShit solution to some admin task like changing the ACLs of a directory tree recursively. It involved including a C# program as a herestring, passing it to the C# compiler, and loading the resulting bytecode. The advocate said "Isn't this beautiful and elegant?"
But in principle the model embraced by PowerShell is strictly more robust than bash's fragile "dumb byte pipes" model.
"Get a byte, get a byte, get a byte, byte, byte!" --NT architect Dave Cutler, on Unix I/O
- Someone1234 11y agoAnd the UNIX style has a cost: It is insecure e.g. [0][1]. Luckily modern UNIX-based systems are rarely used as multi-user terminals these days or we would see many more privilege escalations via exploiting bugs in scripts which iterate over user owned files. Even in web scenarios, most web frameworks carefully manage what is allowed in a filename or set the filename themselves. Ultimately because on UNIX there is no type, you have to make assumptions. These assumptions are sometimes dangerously wrong. You can definitely write scripts and execute commands in a more secure way, but you can go google Linux tutorials right now and find tons of examples where newbies are taught to do it wrong out of the gate. Data types make this "secure by default." String for everything requires the script-writer or command line-writer to be perfect every time they hit return. [0] http://www.defensecode.com/public/DefenseCode_Unix_WildCards_Gone_Wild.txt http://www.defensecode.com/public/DefenseCode_Unix_WildCards... [1] https://www.helpnetsecurity.com/2014/06/27/exploiting-wildcards-on-linux/ https://www.helpnetsecurity.com/2014/06/27/exploiting-wildca...
- striking 11y agoBash scripts aren't usually intended to be secure. They're quickly written one-offs that do some tiny task and do it well, not usually exposed to an insecure environment or externally controlled input. If you want to write a good program, use a programming language that cares about good programming. Bash et al. don't care about how good the program is, they care about getting something done quick.
- verbatim 11y agoWell, that's what we thought before the ShellShock vulnerability ended up being a major security worry due to all of the places that bash scripts end up being used.
- striking 11y agoBash doesn't come with a guarantee of usability sticker. Actually, it comes with an indemnification of liability sticker. People who are dumb enough to hammer in screws shouldn't be building houses. Whether they do or not isn't exactly my worry. Don't use the wrong tool for the job and you probably won't get burned.