fiftydinar / gidro-os

My personalized custom OS image.
Apache License 2.0
15 stars 1 forks source link

`UX & maintenance`: Refactor bash scripts in a more reliable shell language #20

Open fiftydinar opened 6 months ago

fiftydinar commented 6 months ago

Intro

This also includes just scripts, which utilize bash.

The goal is to make scripts more reliable & easier to maintain in the future.

While current bash scripts are reliable enough, there is still some area where this can be improved.

Why shell language & not dedicated programming language?

Because shell language is easier to learn & maintain for simple scripts.

Which shell language to use

I aim to use Oils (formerly OilShell): https://www.oilshell.org/

I find it a great candidate due to these reasons:

Other similar shell languages to bash like fish or zsh don't contain enough improvements for me to use it.

Radically different shell languages like nushell & others are not for me, since I like Bash syntax better as I can understand & read it easier.

Here's the Oils developer take on nushell vs oils (old & probably inaccurate about some nushell issues): https://www.reddit.com/r/ProgrammingLanguages/comments/ddhmj9/comment/f2htup3/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

BlueBuild modules

Currently, the policy for making official BlueBuild modules is that they should be written in bash. This can change over time, as there is a discussion regarding using more reliable language for official BlueBuild modules: https://github.com/blue-build/modules/issues/212

Just scripts

While those work relatively well, I believe they can be improved.

The biggest issue is that just scripts currently look messy.

While reliability of those are alright, I think that it can be improved, to account for other possible scenarios.
Better shell language would make this maintenance easier.

xynydev commented 6 months ago

You could add your case for oil / ysh in the alternative shell discussion for BlueBuild, since there's no consensus yet.

fiftydinar commented 6 months ago

You could add your case for oil / ysh in the alternative shell discussion for BlueBuild, since there's no consensus yet.

I added initial impressions on it, will tell more when I get more deep into it.

fiftydinar commented 4 months ago

To improve just scripts readability, I can put them in organized folder like: /usr/libexec/gidro-os-just-scripts/. Those scripts shouldn't be executed directly by the binary name, so that's why they should be in /usr/libexec/, rather than in /usr/bin/.

So those just scripts will instead manually call those bash binaries with all the code content in 1-liner.

This would allow to reformat just scripts to look cleaner with newlines, which are not allowed in just syntax. It would also show bash syntax properly in the Text Editor, which would help me to code better.