Package: runit
Version: 2.1.2-50
Severity: minor
Tags: patch

Hi,

I'm not satisfied with this bit from /etc/runit/1:

--- 8< ---
if [ -f /etc/runit/native.boot.run ] || [ -n "$bootrun" ]; then
        bootrun=1
fi

if [ -d /etc/runit/boot-run ] && [ ! -z $bootrun ]; then
        for f in /etc/runit/boot-run/*.sh; do
                [ -r "$f" ] && . "$f"
        done
else
        /lib/runit/run_sysv_scripts '/etc/rcS.d'
fi

--- >8 ---

On the one hand, '-z $bootrun' looks like an accident waiting to happen due to 
the missing quotes around "$bootrun". On the other, '[ ! -z "$bootrun" ]' and 
'[ -n "$bootrun ]' mean the same thing, so why do it two different ways within 
five lines?

Furthermore, the two ifs seem redundant; I think the code would be more 
succinct and more readable the following way:

--- 8< ---

if [ -f /etc/runit/native.boot.run -o -n "$bootrun" ] && [ -d 
/etc/runit/boot-run ]; then
        bootrun=1       # set this because sourced scripts might use it, I 
guess (although they wouldn't get run if bootrun weren't set, so setting 
bootrun=1 looks completely superfluous)
        for f in /etc/runit/boot-run/*.sh; do
                [ -r "$f" ] && . "$f"
        done
else
        /lib/runit/run_sysv_scripts '/etc/rcS.d'
fi

--- >8 ---

I think this is equivalent with the exception that it only sets bootrun=1 if 
the /etc/runit/boot-run directory exists; but since nothing in the original 
script uses $bootrun, this doesn't seem to matter (and, as noted above, setting 
bootrun=1 seems completely redundant).

AndrĂ¡s

-- 
               A conclusion is where you got tired of thinking.

Reply via email to