From owner-svn-src-head@FreeBSD.ORG Thu Jul 31 22:00:37 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C1CECFD4; Thu, 31 Jul 2014 22:00:37 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AFE3A2EAD; Thu, 31 Jul 2014 22:00:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6VM0bQk034693; Thu, 31 Jul 2014 22:00:37 GMT (envelope-from dteske@svn.freebsd.org) Received: (from dteske@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s6VM0bKt034692; Thu, 31 Jul 2014 22:00:37 GMT (envelope-from dteske@svn.freebsd.org) Message-Id: <201407312200.s6VM0bKt034692@svn.freebsd.org> From: Devin Teske Date: Thu, 31 Jul 2014 22:00:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r269351 - head/usr.sbin/bsdconfig/share X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jul 2014 22:00:37 -0000 Author: dteske Date: Thu Jul 31 22:00:36 2014 New Revision: 269351 URL: http://svnweb.freebsd.org/changeset/base/269351 Log: Define a setvar() function for platforms using a shell unlike FreeBSD's sh(1) for `/bin/sh' (e.g., bash(1) which lacks a setvar definition). This is to improve portability to other Operating Systems (e.g., Linux). Modified: head/usr.sbin/bsdconfig/share/common.subr Modified: head/usr.sbin/bsdconfig/share/common.subr ============================================================================== --- head/usr.sbin/bsdconfig/share/common.subr Thu Jul 31 20:55:05 2014 (r269350) +++ head/usr.sbin/bsdconfig/share/common.subr Thu Jul 31 22:00:36 2014 (r269351) @@ -220,6 +220,32 @@ f_have() f_quietly type "$@" } +# setvar $var_to_set [$value] +# +# Implement setvar for shells such as unlike FreeBSD sh(1). +# +if ! f_have setvar; then +setvar() +{ + [ $# -gt 0 ] || return $SUCCESS + local __setvar_var_to_set="$1" __setvar_right="$2" __setvar_left= + case $# in + 1) unset "$__setvar_var_to_set" + return $? ;; + 2) : fall through ;; + *) f_err "setvar: too many arguments\n" + return $FAILURE + esac + while case "$__setvar_r" in *\'*) : ;; *) false ; esac + do + __setvar_left="$__setvar_left${__setvar_right%%\'*}'\\''" + __setvar_right="${__setvar_right#*\'}" + done + __setvar_left="$__setvar_left${__setvar_right#*\'}" + eval "$__setvar_var_to_set='$__setvar_left'" +} +fi + # f_which $anything [$var_to_set] # # A fast built-in replacement for syntaxes such as foo=$( which bar ). In a