Bashism in /etc/rc.d/rc.S
as an experiment (and to get rid of bash) i changed /bin/sh to point to /bin/mksh.
the boot process fails at line 109 in /etc/rc.d/rc.S: eval LUKSARRAY=( $line ) This line, and the following lines LUKS="${LUKSARRAY[0]}" DEV="${LUKSARRAY[1]}" PASS="${LUKSARRAY[2]}" OPTS="${LUKSARRAY[3]}" look like bash code to me. Affected is X86_64 current and i686 14.1. I am not an shell expert, can someone confirm this? Or provide a simple solution? Otherwise I will sot down and write a patch to solve this issue. heiko |
Why would you switch to the korn shell?
If you think that little bashism is bad, just wait... nearly all the startup scripts have bashisms in them. I could understand switching to something like ash or busybox (useful for very small distributions)... but the korn shell? |
Yep, unfortunately a number of important Slackware initscripts contain bashisms. :(
Gilbert did some nice work on POSIX compliant startup-scripts a while back, which you may find useful: http://www.linuxquestions.org/questi...1/#post5156115 Only problem is that once you start making changes like this you're stepping outside of "Official Slackware" and that may make your system maintenance more difficult when Pat ships a new set of init-scripts. |
Quote:
|
Quote:
i don't mind using bash for the rc scripts, but if bash is required a "/bin/bash" shebang line should be used instead of "/bin/sh". |
Well, I think that Pat just follows the old saying here "if it ain't broke, don't fix it". If he were to rewrite all the init scripts from scratch, maybe he would use another syntax here and there. But there is no need for that as far as I know (please no more flame war about _you_know_what_).
|
I giggled when I saw this recently.
From pm-functions (part of pm-utils) Code:
#!/bin/sh BTW There are also bashisms in the code, despite the /bin/sh shebang. Removing bash is a larger task than just looking at the init scripts. |
Quote:
You'd remove bash at your peril. I added bashisms into the initrd 'init' script because it meant I could achieve a string manipulation inside of bash rather than forking to some other utilities. In my opinion since you're using a particular language which is mandated to be present, you should exercise its abilities where possible - particularly if it helps improve efficiency. If these scripts were intended to be used outside of Slackware then it would make sense to make them as POSIX compliant as possible to maximise their usability. But they aren't. |
Quote:
|
Any initrd is a special case. In this case, whether you mean the intrd from the installer, or one generated by mkinitrd, bash is not included. rc.S and all other init scripts are not used by the initrd. Any scripts run by the initrd will be busybox/sh compatible -as are doinst.sh scripts.
|
Quote:
Quote:
Quote:
|
Quote:
|
About the only place I would expect bashisms to be rare would be those multi-platform packages that are expected on things like AIX and SunOS. Though even there, bash is also frequently installed on the system.
|
Quote:
First, the LUKSARRAY array is created via: Code:
cat /etc/crypttab | grep -v "^#" | grep -v "^$" | while read line; do ... ; done On a secondary note, that could be replaced with: Code:
egrep -v '(^#|^$)' /etc/crypttab | while read -r line; do ... ; done Quote:
I see a related thread in the "Similar Threads" section and it asks "anyone uses ash as /bin/sh?" which is probably the closest to a POSIX/bourne shell that Slackware has. There are some things that aren't part of the bourne shell or defined by POSIX in the almquist shell (local for example), but it's pretty close. |
I actually don't mind bash when it's running in bash mode, and some of the bashisms are actually quite useful. It's when it's trying to take on its POSIX persona when run as 'sh' that you start to hit problems, particularly around shell invocation.
BTW, doesn't debian use 'dash' to provide their /bin/sh? |
All times are GMT -5. The time now is 02:58 PM. |