View previous topic :: View next topic |
Author |
Message |
needMoreFirmware n00b
Joined: 21 Mar 2018 Posts: 21
|
Posted: Wed Mar 28, 2018 11:45 am Post subject: [solved] dash as /bin/sh |
|
|
How viable is it?, the wiki states that some scripts on Gentoo have bashisms on them, I checked the init scripts at /etc/init.d/ with checkbashisms for a quick check and they all seemed to be fine, where else should I look for bashisms before trying to replace /bin/sh with dash?, or should I even try it at all?
Last edited by needMoreFirmware on Wed Mar 28, 2018 6:24 pm; edited 1 time in total |
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6051 Location: Removed by Neddy
|
Posted: Wed Mar 28, 2018 11:56 am Post subject: |
|
|
OpenRC always planned to be POSIX compliant and thus only sh can be used.
This should not have changed thus dash is a viable drop-in _________________
Quote: | Removed by Chiitoo |
|
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3335 Location: Rasi, Finland
|
Posted: Wed Mar 28, 2018 1:40 pm Post subject: |
|
|
I know Alpine Linux uses dash only as default and also uses OpenRC. So OpenRC itself does not need bash.
So, as stated, it's up to the init/OpenRC scripts if they adhere POSIX/sh standard. I'd assume no bashism is introduced in offical Gentoo init scripts, unless by accident. Raise a bug if you see one. _________________ ..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
needMoreFirmware n00b
Joined: 21 Mar 2018 Posts: 21
|
Posted: Wed Mar 28, 2018 1:56 pm Post subject: |
|
|
Would there be anything else I need to worry about? (if it's not OpenRC). |
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Wed Mar 28, 2018 5:24 pm Post subject: |
|
|
dash works fine, that's why we have a eselect-sh package. |
|
Back to top |
|
|
needMoreFirmware n00b
Joined: 21 Mar 2018 Posts: 21
|
Posted: Wed Mar 28, 2018 6:21 pm Post subject: |
|
|
Seems to work fine, I had doubts since I couldn't find much info on it at all. |
|
Back to top |
|
|
depontius Advocate
Joined: 05 May 2004 Posts: 3509
|
Posted: Thu Mar 29, 2018 8:19 am Post subject: |
|
|
It's lost in the distant past, but I had one particular package where I had to change /bin/sh back to bash in order for it to build properly. I forget how I debugged it, but I found it here on the forums. Then I went back to dash for normal operation - been there for years. _________________ .sigs waste space and bandwidth |
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6051 Location: Removed by Neddy
|
Posted: Thu Mar 29, 2018 11:44 am Post subject: |
|
|
Zucca wrote: | helecho wrote: | A script begins with a [url=https://en.wikipedia.org/wiki/Shebang_(Unix)]shebang[/url] so there will be no problem. | About shebangs...
Does anyone know if OpenRC is "flexible enough" to support different interpreters via shebang? For example if someone crazy anough would want to write a init script in lua? (I'm not.) This, of course, creates a whole new set of problems because functions and variables aren't passed to the lua environment (well, variables maybe).
Moreover, does OpenRC even respect the shebang or does it automatically run the init script using /sbin/openrc-run? | I have just looked over the openrc code... it "sources" the config file thus the config needs to be sh/bash. The actual init script... I have not found whether it sources or executes.
If it sources and then calls the relevant stage functions within the local namespace then it is then limited to sh/bash, if however it executes then as long as you match the api it should work (tm) BUT such init scripts hopefully wouldn't be accepted by upstream as it would not be POSIX compliant _________________
Quote: | Removed by Chiitoo |
|
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3335 Location: Rasi, Finland
|
Posted: Thu Mar 29, 2018 11:57 am Post subject: |
|
|
Naib wrote: | BUT such init scripts hopefully wouldn't be accepted by upstream as it would not be POSIX compliant | awk is afaik. _________________ ..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Fri Mar 30, 2018 4:49 am Post subject: |
|
|
Zucca wrote: | Does anyone know if OpenRC is "flexible enough" to support different interpreters via shebang? For example if someone crazy anough would want to write a init script in lua? :D (I'm not.) This, of course, creates a whole new set of problems because functions and variables aren't passed to the lua environment (well, variables maybe).
Moreover, does OpenRC even respect the shebang or does it automatically run the init script using /sbin/openrc-run? |
According to /usr/share/doc/openrc-*/service-script-guide.md it won't stop you from doing things like that, but you're definitely on your own if you do. You should probably provide at least the command line commands listed in openrc-run(8), but it won't be able to use dependencies unless you reimplement that yourself. |
|
Back to top |
|
|
|