Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] dash as /bin/sh
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
needMoreFirmware
n00b
n00b


Joined: 21 Mar 2018
Posts: 21

PostPosted: Wed Mar 28, 2018 11:45 am    Post subject: [solved] dash as /bin/sh Reply with quote

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
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Wed Mar 28, 2018 11:56 am    Post subject: Reply with quote

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
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3335
Location: Rasi, Finland

PostPosted: Wed Mar 28, 2018 1:40 pm    Post subject: Reply with quote

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
View user's profile Send private message
needMoreFirmware
n00b
n00b


Joined: 21 Mar 2018
Posts: 21

PostPosted: Wed Mar 28, 2018 1:56 pm    Post subject: Reply with quote

Would there be anything else I need to worry about? (if it's not OpenRC).
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Wed Mar 28, 2018 5:24 pm    Post subject: Reply with quote

dash works fine, that's why we have a eselect-sh package.
Back to top
View user's profile Send private message
needMoreFirmware
n00b
n00b


Joined: 21 Mar 2018
Posts: 21

PostPosted: Wed Mar 28, 2018 6:21 pm    Post subject: Reply with quote

Seems to work fine, I had doubts since I couldn't find much info on it at all.
Back to top
View user's profile Send private message
depontius
Advocate
Advocate


Joined: 05 May 2004
Posts: 3509

PostPosted: Thu Mar 29, 2018 8:19 am    Post subject: Reply with quote

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
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Thu Mar 29, 2018 11:44 am    Post subject: Reply with quote

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? :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?
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
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3335
Location: Rasi, Finland

PostPosted: Thu Mar 29, 2018 11:57 am    Post subject: Reply with quote

Naib wrote:
BUT such init scripts hopefully wouldn't be accepted by upstream as it would not be POSIX compliant
awk is afaik. :twisted:
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Fri Mar 30, 2018 4:49 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum