I started wondering today, why are we using arcane shells? Don't get me wrong, bash, zsh, fish, I like them all, but can't we do better by now? What do I mean by better? Short answer - drop the C. Long answer - let me ask a couple more questions:
- If I want to write a function that counts something, why do I have to return it as a string? And how do I return it in the first place? By echoing it and capturing that in a var? By setting a global variable? By using eval tricks?
- If I want to know a file's extension, why do I have to manipulate strings?
- What the hell is this?
${#files[@]}
For simple scripting these are non-issues but not many people enjoy writing e.g. bash scripts that get over 1k lines. It's just too tedious and error prone. What I'm looking for is simple:
- To count the files in the current directory I don't want to say
find . -type f -maxdepth 1 | wc -l
and listen to people preaching me this is still wrong because filenames can contain newlines. That's my problem in the first place, I had no intention to count lines, I just want the number of files in the folder. I want to be able to saycurrentDir.files.count
orlength (files (dir "."))
etc. - To get the extension of a file I don't want to say
"${file##*.}"
and start wondering what if my file doesn't have one to begin with. I want to sayfile.extension
orgetExt file
and move on. - To work with running processes I don't want to have
ps
,pgrep
,kill
etc., I want to have a list of running processes and be able to filter on them by name, uptime, user etc., create a report, batch kill them, you get the point.
The question aimed at you, reader, is - why aren't we doing this? Why aren't there shells/repls/clis written in python/ruby/haskell/lisp/... ? What is stopping us?
https://github.com/trogdoro/xiki