Seriously I don't know why you'd do this in Bash. Crazy choice.
I do not understand them.
tail -n 8 $HISTFILE > script.sh
and very little to no editing is needed to make that useful. Shell is not a programming language, it's an interface to the OS, and thinking about it like a programming language is just asking for frustration.I guess this just isn’t obvious to me. Where do you see the boundary between “interface to the os” and “programming language”?
It also has no other dependency, which is also good. I have written helper script to run coding agents in a container. And you guessed it, it's in bash. For the reasons I just wrote down. Should it have to grow I would rewrite it, but not currently.
I remember somebody once telling me that they had learned vi because "it was always installed". Well, no, technically, the only editor you can be sure is there is ed. So, you know, learn that. I was surprised that they actually did.
Bash is syntactically not perfect, I agree. However it's a well known, mature, stable environment. LLMs can write it well if you need them to. If it was perfect, we'd never have had Perl, and as a result we'd never have had Ruby, Python and other scripting languages.
But I like it's a tool that doesn't require me to go reach for a package manager and some build tools I don't always have on every system.
Then you wonder why it doesn’t work in your other environment. Then you find that GNU vs BSD sed have different syntax.
Better to start with Python once you’re doing more than coordinating well known other tools.
Unfortunately, ed has been omitted from the default installation of recent debians, at least. I had to install it manually.
If I wanted an OS without a text editor, I'd use emacs.