A shell for perfectionists?

Hello.

I'm only starting to know about shell scripting, but I was totally surprised and disappointed when I've discovered there are no really comfortable tools in bash that are present in any programming language. I mean, if you already know the basics of some programming language, in most cases you will easily understand the same basics in other PL, you just need to get used to the new syntax. And bash just exploded my brains with its logic. I know it's not a PL, but since a shell do the same tasks when it comes to using basic features in scripting, I expected it will be relatively the same. The simpliest task of creating nested arrays in bash requires this (!!!). How one can even script with comfort with such a tool? I understand, it was created lightweight to do simple tasks, but if it has arrays, why shouldn't it have nested arrays? I can't even imagine, why create basic features that are so hard in use that they would better not exist in a shell at all. If a shell must be lightweight and thus cannot be usable for comfortable scripting, let's leave it alone for non-scripting tasks - otherwise, there is no point in creating a tool for comfortable scripting if it's known from the start that the scripting will not be comfortable.

So... does anybody know a shell that is more predictable and less... ■■■■■■■■■-like? A structured, logical, clear tool that is working for you, not the opposite.

If you want something more like a programming language, write your scripts in a programming language.

You will eventually get used to writing shell scripts but it is a unique experience.

You might consider using something like python for your scripting. It is interpreted and most systems will already have a python environment.

The better way to understand bash is that it wasnt built with most modern uses in mind. But it is often adaptable enough to accomplish many tasks it was not designed to handle.

You will get slightly more familiar syntax in something like tcsh but it isn't very widely used and once you get past the syntax you start to realize how limited it really is.

bash is pretty much the standard for shell scripting.

I want to use the same basic features existing in any PL. Variables, arrays, loops, etc. I don't need all the abilities of PLs in shell - just the features that mostly are already implemented. I want something more like a PL to use as a shell, but I don't want to use a PL instead of a shell and I don't want for a shell to be as monstrous as PL.

I don't like the idea of using insufficient tools instead of searching or creating a more comfortable tool and I don't want to create monstrous workarounds for daily tasks just because most of people use bash and thus do the same.

On Windows I hear you can install the “Windows Subsystem for Linux”.

Oh wait, that's just Microsoft's implementation of "bash". Silly me. :wink:

zsh has more advanced features but it still doesn't have multidimensional arrays.

From your descriptions, a shell script is not what you want.

That being said, you may just need to give it more time to become accustomed to it. It is a pretty big adjustment coming from another language. They pretty much all have variables, arrays, loops and conditionals. It just doesn't work the way many other languages do. Also, you really have to get used to thinking differently to be effective.

Alternatively, there are plenty of lightweight scripting languages that might be more like what you have in mind.

Well then .. I think you have yourself a conundrum..

Also, you really have to get used to thinking differently to be effective.

The problem is not in my inability to use bash effectively - I'm more than accustomed to changing my ways of thinking for learning something and be effective, and I'm pretty sure, eventually I would script stuff effectively, it just requires some subtle understanding and practice, as with anything else. But it just won't be comfortable. I don't need just something to use for easy scripting - I need something logical, structured and predictable to use for scripting, even it is hard in leaning. I'm searching for a tool that will not enrage my inner perfectionist and I have pretty much free time to learn anything I need to seize the tool I liked. So, the question is not "what is the easiest shell", but "what is the best shining shell for those who are ready to go to the edge of the Earth for a better piece of software".

I guess then the answer is ... whatever shell you develop yourself.

1 Like

From a scripting perspective, there just isn't that much difference.

ash/bash/ksh/zsh are all really evolutions/extensions of sh. While there are obvious differences between them in functionality, they mostly feel the same and have similar syntax. zsh is the most modern of these.

tcsh is an evolution of the old csh shell and is quite a bit different but it is still quite dated.

fish is also different but it is mostly intended to be an interactive shell.

3 Likes

I hoped there will be another answer)

Well, if someone have heard about another someone that have developed the described tool, I'd apperciate if you share. Because I have a really big list of perfect things I need to develop)

Thanks. That helped a bit.

https://wiki.archlinux.org/index.php/Command-line_shell

When scripting, I use

  • dash for performance. Small scripts that executed multiple times per second
  • bash for portability. Most of my stuff is in bash, especially interactive scripts where performance doesn't matter
  • zsh for features. Mainly floats in arithmetic evaluation, but you can also replace for example sed calls with inbuilt features
  • python for more complicated stuff. It's about as simple as shells, but has the power of a real pl.

Usually you use shell scripts mostly to call other programs, because that is what they are actually for. If you actually need arrays, your task is usually too complicated for a shell script anyway imho.

3 Likes

I think you should look for Python,
Or if you crazy for performance, look for Julia.

Or write your own shell, but I think it's not worth the time.

I'm liking Julia a lot.

Anyway, I hope I could help :smile:

2 Likes

The point of quiestioning here was that if there is someone with the same experience on the forum, his recommendations would be far more trustworthy for me than some vague articles I can google in Web.

Usually you use shell scripts mostly to call other programs, because that is what they are actually for. If you actually need arrays, your task is usually too complicated for a shell script anyway imho.

And that is confusing. If a shell should just call other programs - let it do it, why loops or arrays were even implemented? And if they should be in a shell, then why they are so unusable?

I dunno about arrays, in my perspective looks useless to me in a shell, but loops are quite useful, considering you want to run the same program again and again just changing a bit in the parameter.

The linked articles aren't vague. You didn't write anything about "only people who have personal experience" are welcome to post.

My point is there is no such thing as weird requirement. There will always be someone who implemented the weirdest thing in GNU/Linux.

Forum kindly sponsored by