From owner-freebsd-hackers@FreeBSD.ORG Mon Oct 11 04:17:29 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 621A1106564A; Mon, 11 Oct 2010 04:17:29 +0000 (UTC) (envelope-from swell.k@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id B8EF48FC19; Mon, 11 Oct 2010 04:17:28 +0000 (UTC) Received: by fxm12 with SMTP id 12so566611fxm.13 for ; Sun, 10 Oct 2010 21:17:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject :in-reply-to:references:user-agent:date:message-id:mime-version :content-type; bh=r0aLOjS0UXVx4+4EoXaAGGExTm1F3SHco3V1/jCosH0=; b=VH7BsFazsIPNagF0ESZauvOmqS1CG6E9vDjYFIXyvqp9Zz9SisseU2ytoLKb/PhYl/ NSijwmRCuOFW0Iq6U2f0PMxnE1wtyMFcA7A8vLjGQoIRg3lp0qaCb0XTWNI+s/BfLsov NGsmZlsGGRA9qF2kJNMDgw7LNG0DBuxgJn/ns= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type; b=YhNWFgyk+fL8jTBrgoR77PxKIbNDZRYab6C+EI9XAIyFgOJLWukOIRjs5l99SNDFmo /Qug3hstiMvQZzmPAeBrn0+CY40MK9UtbL5yzsOoEpxTvd5cWti8pqoCWaIl2Rajzw6W KvjG8Ocz8SPx25OH9MImSToJAWic96vrmgK+8= Received: by 10.223.114.19 with SMTP id c19mr1511889faq.29.1286768905027; Sun, 10 Oct 2010 20:48:25 -0700 (PDT) Received: from localhost ([85.17.254.135]) by mx.google.com with ESMTPS id d17sm1631789fav.29.2010.10.10.20.48.22 (version=SSLv3 cipher=RC4-MD5); Sun, 10 Oct 2010 20:48:23 -0700 (PDT) From: Anonymous To: Devin Teske In-Reply-To: <238E0B24-AA12-4684-9651-84DA665BE893@vicor.com> (Devin Teske's message of "Sat, 9 Oct 2010 15:39:44 -0700") References: <1286397912.27308.40.camel@localhost.localdomain> <51B4504F-5AA4-47C5-BF23-FA51DE5BC8C8@vicor.com> <238E0B24-AA12-4684-9651-84DA665BE893@vicor.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix) Date: Mon, 11 Oct 2010 07:48:19 +0400 Message-ID: <86lj65ie4c.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Cc: Brandon Gooch , freebsd-hackers@freebsd.org, Garrett Cooper Subject: Re: sysrc -- a sysctl(8)-like utility for managing /etc/rc.conf et. al. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Oct 2010 04:17:29 -0000 Devin Teske writes: >>> ############################################################ GLOBALS >>> >>> # Global exit status variables >>> : ${SUCCESS:=0} >>> : ${FAILURE:=1} >> >> Should this really be set to something other than 0 or 1 by the >> end-user's environment? This would simplify a lot of return/exit >> calls... > > A scenario that I envision that almost never arises, but... > > Say someone wanted to call my script but wanted to mask it to always return with success (why? I dunno... it's conceivable though). > > Example: (this should be considered ugly -- because it is) > > FAILURE=0 && sysrc foo && reboot Wouldn't this bork functions used inside a conditional? : ${FAILURE:=1} foo() { return ${FAILURE-1}; } if ! foo; then echo good else echo error fi $ test.sh good $ FAILURE=0 test.sh error I think only sysrc_set() is affected, though. if sysrc_set "$NAME" "${1#*=}"; then echo " -> $( sysrc "$NAME" )" fi $ sysrc hostname=blah hostname: raphael.local sysrc: cannot create /etc/rc.conf: permission denied $ FAILURE=0 sh sysrc hostname=blah hostname: raphael.local sysrc: cannot create /etc/rc.conf: permission denied -> raphael.local