4 ms·
I have been thinking about an alternative to bash/POSIX style shells, and I find powershell kind of genius in this regard. What could potentially work for the
by kaba0 6y ago
I have been thinking about an alternative to bash/POSIX style shells, and I find powershell kind of genius in this regard.
What could potentially work for the linux world is perhaps dbus objects between piped programs (they are easy to read/write even from lower level languages) and some way for programs to communicate whether they are capable of interpreting objects, or should fall back to string based communication. And at the boundaries there could be automatic translations (though object to string is easier) with something like toString.
So for example `ls -la | filter f -> f.date > 2021-01-01 | grep something` would either shadow ls to a new shell-aware implementation or patch it /interpret automagically the table layout and then the resulting list of objects could be filtered and at the end reconverted to an object “toString” per each line which can be operated on by grep
- geophile 6y agoIn marcel: M 0.12.7 jao@cheese ~$ import datetime datetime M 0.12.7 jao@cheese ~$ ls | select (f: f.mtime > datetime(2021, 1, 1).timestamp()) | grep py .marcel.py .python_history ls is builtin (and has -la behavior by default), select is provided by marcel, and grep is from the host OS. Note that the python function datetime.datetime is imported so that it can be used in the select predicate.
- svnpenn 6y agoPowerShell works with Linux...
- kaba0 6y agoYeah I know. It is not really a first-class citizen though.
- electricEmu 6y agoPOSIX commands are available on *nix platforms and PowerShell provides native functions or POSIX wrappers for most tasks. About the biggest issue is speed, but there's always POSIX or .NET Core in the rare instance tons of performance is required. If I may, PS is a first-class citizen on Linux, macOS, and Windows. PowerShell is a spectacular cross-platform shell that provides an object oriented paradigm and it's available today.
- electricEmu 6y agoPowerShell runs on Linux. I run PS as my primary shell [0] on Linux today. It's is open source too. You're not far away with how PowerShell can parse Linux commands. Instead of relying on awk/grep, PowerShell uses .NET under the hood to provide consistency across operating systems. There are a few methods for converting from a Linux command to PowerShell objects based on delimiters or OFS. If you're interested, Steve Lee wrote a blog post that does a good job covering how to parse Linux command output into PowerShell objects [1]. [0] https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-linux?view=powershell-7.1 https://docs.microsoft.com/en-us/powershell/scripting/instal... [1] https://devblogs.microsoft.com/powershell/parsing-text-with-powershell-1-3/ https://devblogs.microsoft.com/powershell/parsing-text-with-...
- kaba0 6y agoYeah, I know about it running on linux and even tried to use it as a default shell for a time. Thanks for the links though, I didn’t dive this deep into it.