Open williamh opened 5 years ago
I don't know that there would need to be any code changes for the internal code in openrc, simply changing the shebang should do the trick.
Only changing the shebangs would require changing the shebangs at build time in openrc-run.sh and gendepends.sh as well as assuming that all posix compatible scripts would run under bash in full bash mode.
If this change is made, all service scripts on your system would then be running under bash instead of bash in sh mode. Is it reasonable to assume that all service scripts can run under full bash?
If you want to test, make those changes on a system, reboot it and see what happens.
In my opinion, its a disproportional amount of effort to implement it compared to the gains. If I understand correctly, for each shell, you'd need scripts made for the specific shell. I would see difficulties to keep them all in sync, bashism specific stuff, posix, zsh whatever. Is that wise, or differently asked, what is the big gain of this exercise other than being able to write bash openrc-run?
@udeved The plan is to allow this as long as it doesn't interfeer with the base code of OpenRC. Bash can understand posix shell even in bash mode from what I understand, so we can make it work as long as the code that interfaces directly with openrc-run.sh is posix. I'll push a commit shortly.
i would restrict this a bit rather than completely opening it to any shell (as that basically means any interpreter, e.g. Python). stipulate that POSIX shell must be supported, and then make it an option on a per-init.d script basis. if we supported options in the header of the init.d script (maybe require it be the 2nd line?), then openrc-run could parse that at runtime, and then change from /bin/sh
to something else.
using the shebang might also be an option, but we'd have to take care to split+parse that ourselves since the syntax only supports a single option (including whitespace). and it can be limited in how long it can be by the kernel.
All,
I am opening this because one of our downstream users has requested that we make it possible and I would like to gather thoughts about doing it.
OpenRC has never officially supported any script language other than posix shell for service scripts. Sometimes you have been able to get away with non-posix code, but not always.
I have been asked to allow bashisms in service scripts.
My thought is that, in order to do so, we would need to maintain multiple copies of, at least, gendepends, and maybe any other *.sh script in OpenRC, to run under each shell we support.