Welcome to CRUX bug tracking.

FS#1065 - Changes for using dash as /bin/sh

Attached to Project: CRUX
Opened by novak (novak) - Thursday, 02 October 2014, 20:27 GMT
Last edited by Fredrik Rinnestam (frinnst) - Tuesday, 04 August 2015, 11:48 GMT
Task Type Improvement
Category ports → core/opt
Status Closed
Assigned To No-one
Operating System CRUX
Severity Low
Priority Normal
Reported Version 3.1
Due in Version 3.2
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


This is probably not exhaustive, I just switched my /bin/sh to dash and I've been looking for things that have to be changed. I'll put the diffs for rc.multi,single, and shutdown up once I get them, they are certainly going to have to be changed though because of both array syntax and comparisons. They actually explicitly call /bin/bash though, so they can be left for the time being.

Known required changes:

File list:

bash-4.3# diff rc.d/net rc.d/net~
< if [ "$TYPE" = "DHCP" ]; then
> if [ "${TYPE}" = "DHCP" ]; then
< if [ "$TYPE" = "DHCP" ]; then
> if [ "${TYPE}" = "DHCP" ]; then

bash-4.3# diff rc.d/sshd rc.d/sshd~
< kill $(cat /var/run/
> kill $(< /var/run/

This task depends upon

Closed by  Fredrik Rinnestam (frinnst)
Tuesday, 04 August 2015, 11:48 GMT
Reason for closing:  Fixed
Additional comments about closing:  fixed for 3.2.

init-scripts will remain bash scripts for now.
Comment by Danny Rawlins (Romster) - Friday, 03 October 2014, 08:34 GMT
Could you please use diff -u for unified diff. is easier to read.
Comment by Juergen Daubert (jue) - Monday, 06 October 2014, 14:01 GMT
Your fix for rc.d/net is wrong:

- ${TYPE} is a valid sh syntax, but == in the test statement is not but should be =

Comment by Juergen Daubert (jue) - Friday, 30 January 2015, 17:22 GMT
It's useless to change our rc-scripts to be sh compatible, because essential CRUX programs like pkgmk and ports are written for bash and therefor bash is a core requirement for CRUX at the moment.

However it seems to be sensefull to use dash for /bin/sh, because:

a) performance increase for buildig ports. All the auto*/libtool stuff calls /bin/sh very often, typical more than 1000 calls for a medium port. I've done some rough messurements, see here:
b) dash might be more secure than bash, because of the much smaller code base

But, we have to do extensive tests to see if and how many ports will break with dash as /bin/sh.
Comment by Camille (onodera) - Wednesday, 29 July 2015, 14:34 GMT
We could also change the init to, it's already posix SH, simpler (in my opinion) than the current rc, and it uses busybox init (although there are also a few forks that use sinit, even more minimal).