Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Jan 2013 15:04:20 GMT
From:      Tatsuki Makino <tatsuki_makino@hotmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   conf/175105: /etc/rc.d/* and more: syntax 'return_boolean_cmd && do_cmd_if_true' executed last returns unexpected value
Message-ID:  <201301071504.r07F4KMs061927@red.freebsd.org>
Resent-Message-ID: <201301071510.r07FA1i6034028@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         175105
>Category:       conf
>Synopsis:       /etc/rc.d/* and more: syntax 'return_boolean_cmd && do_cmd_if_true' executed last returns unexpected value
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 07 15:10:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Tatsuki Makino
>Release:        FreeBSD 8.3-STABLE i386
>Organization:
>Environment:
FreeBSD T2.test 8.3-STABLE FreeBSD 8.3-STABLE #0 r245032M: Fri Jan  4 07:36:05 UTC 2013     root@T2.test:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
If the shell script that has 'false && true' line, $? set not 0. If that line execute last, then shell script returns not 0.

sub probrem: conf/175006
>How-To-Repeat:
# echo 'ip6addrctl_verbose="NO"' >> /etc/rc.conf
# /etc/rc.d/ip6addrctl start
# echo $?

# echo 'sysvipc_enable="NO"' >> /etc/rc.conf
# echo 'linux_enable="NO"' >> /etc/rc.conf
# echo 'svr4_enable="NO"' >> /etc/rc.conf
# /etc/rc.d/abi start
# echo $?
>Fix:
1. Use `if' syntax.

if checkyesno foo ; then
  do_foo
fi

1. Execute `true' if false

checkyesno foo && do_foo || true

# If we need result of do_foo
! checkyesno foo && true || do_foo

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201301071504.r07F4KMs061927>