FS#14059 - initscripts: /etc/rc.d/functions exit with 1 status
Attached to Project:
Arch Linux
Opened by Sebastien Vasey (svasey) - Wednesday, 01 April 2009, 19:28 GMT
Last edited by Aaron Griffin (phrakture) - Thursday, 02 April 2009, 16:51 GMT
Opened by Sebastien Vasey (svasey) - Wednesday, 01 April 2009, 19:28 GMT
Last edited by Aaron Griffin (phrakture) - Thursday, 02 April 2009, 16:51 GMT
|
Details
Description:
In any rc script, If I do something like #!/bin/bash set -o errexit # This is what causes trouble source /etc/rc.d/rc.conf source /etc/rc.d/functions And then try to execute the result, the /etc/rc.d/functions script exits with 1 status due to an error happening in its code. Of course, everything works fine if errexit is not set. I don't know if we are supposed to use bash for rc scripts, but it seems to me no error should be left unchecked. I use initscripts-2009.03-2 Steps to reproduce: $ bash $ source /etc/rc.d/functions $ echo $? |
This task depends upon
Closed by Aaron Griffin (phrakture)
Thursday, 02 April 2009, 16:51 GMT
Reason for closing: Fixed
Additional comments about closing: Fixed in git
Thursday, 02 April 2009, 16:51 GMT
Reason for closing: Fixed
Additional comments about closing: Fixed in git
The problem is my /etc/rc.d/functions.d is empty (I don't know what it is for). At the end of /etc/rc.d/functions , there are the following lines
#Source additional functions at the end to allow overrides
for f in /etc/rc.d/functions.d/*; do
[ -e $f ] && . $f
done
Since /etc/rc.d/functions.d/* does not match anything, it is used literally so the test [-e /etc/rc.d/functions.d/* ] is made and fails, making the script directly exit if bash's errexit is on.
A simple fix would be
#Source additional functions at the end to allow overrides
for f in $(ls /etc/rc.d/functions.d/); do
[ -e $f ] && . $f
done
#Source additional functions at the end to allow overrides
for f in /etc/rc.d/functions.d/*; do
if [ -e "$f" ]; then . $f ; fi
done
http://code.phraktured.net/cgit.cgi/initscripts/commit/?id=07d2701e269042015656bfbdacff8349ca77a687