Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fiftydinar opened this issue May 16, 2024 · 3 comments
Labels
maintenance Issues/PRs which can make maintenance easier UX Issues/PRs which can improve user experience when using Gidro-OS

Comments

@fiftydinar
Copy link
Owner

fiftydinar commented May 16, 2024

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:

  • OSH shell mode: I can still code in pure Bash code, while gaining better logging + debugging support & some other minor features & improvements, which can make Bash code quality better. This is possible thanks to POSIX & Bash scripts compatibility.
  • YSH shell mode: It's a more radical Bash successor with major improvements like proper error handling & such. It doesn't deviate from Bash a lot, especially in terms of syntax, which I really like.

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:
blue-build/modules#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.

@fiftydinar fiftydinar added maintenance Issues/PRs which can make maintenance easier UX Issues/PRs which can improve user experience when using Gidro-OS labels May 16, 2024
@xynydev
Copy link

xynydev commented May 17, 2024

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

@fiftydinar
Copy link
Owner Author

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
Copy link
Owner Author

fiftydinar commented Jul 15, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Issues/PRs which can make maintenance easier UX Issues/PRs which can improve user experience when using Gidro-OS
Projects
None yet
Development

No branches or pull requests

2 participants