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

[discussion] make it possible to use bash for service scripts #288

Open
williamh opened this issue Feb 7, 2019 · 5 comments
Open

[discussion] make it possible to use bash for service scripts #288

williamh opened this issue Feb 7, 2019 · 5 comments

Comments

@williamh
Copy link
Contributor

williamh commented Feb 7, 2019

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.

@chutz
Copy link
Contributor

chutz commented Feb 7, 2019

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.

@williamh
Copy link
Contributor Author

williamh commented Feb 7, 2019

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.

@udeved
Copy link
Contributor

udeved commented Feb 8, 2019

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?

@williamh
Copy link
Contributor Author

@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.

@vapier
Copy link
Member

vapier commented Jan 15, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants