From owner-svn-src-all@FreeBSD.ORG Fri Mar 7 20:13:00 2014 Return-Path: Delivered-To: svn-src-all@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 69B25952; Fri, 7 Mar 2014 20:13:00 +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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 3EC11A00; Fri, 7 Mar 2014 20:13:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s27KD0dG026229; Fri, 7 Mar 2014 20:13:00 GMT (envelope-from dteske@svn.freebsd.org) Received: (from dteske@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s27KCxhX026221; Fri, 7 Mar 2014 20:12:59 GMT (envelope-from dteske@svn.freebsd.org) Message-Id: <201403072012.s27KCxhX026221@svn.freebsd.org> From: Devin Teske Date: Fri, 7 Mar 2014 20:12:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262895 - in 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-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Mar 2014 20:13:00 -0000 Author: dteske Date: Fri Mar 7 20:12:59 2014 New Revision: 262895 URL: http://svnweb.freebsd.org/changeset/base/262895 Log: Allow dispatched reswords to carry arguments. Fix a comment while here. Modified: head/usr.sbin/bsdconfig/bsdconfig head/usr.sbin/bsdconfig/share/script.subr Modified: head/usr.sbin/bsdconfig/bsdconfig ============================================================================== --- head/usr.sbin/bsdconfig/bsdconfig Fri Mar 7 19:30:03 2014 (r262894) +++ head/usr.sbin/bsdconfig/bsdconfig Fri Mar 7 20:12:59 2014 (r262895) @@ -324,7 +324,7 @@ if [ "$pgm" != "bsdconfig" ]; then [ "$pgm" = "$resword" ] || continue # Found a match f_dprintf "pgm=[%s] A valid resWord!" "$pgm" - f_dispatch $resword + f_dispatch $resword $resword "$@" exit $? done fi Modified: head/usr.sbin/bsdconfig/share/script.subr ============================================================================== --- head/usr.sbin/bsdconfig/share/script.subr Fri Mar 7 19:30:03 2014 (r262894) +++ head/usr.sbin/bsdconfig/share/script.subr Fri Mar 7 20:12:59 2014 (r262895) @@ -1,6 +1,6 @@ if [ ! "$_SCRIPT_SUBR" ]; then _SCRIPT_SUBR=1 # -# Copyright (c) 2012-2013 Devin Teske +# Copyright (c) 2012-2014 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -50,25 +50,23 @@ RESWORDS= # Create a new `reserved' word for scripting purposes. Reswords call pre- # defined functions but differ from those functions in the following ways: # -# + Reswords do not take arguments but instead get all their data from -# the environment variable namespace. # + Unless noError is set (must be non-NULL), if calling the resword # results in failure, the application will terminate prematurely. # + noError is unset after each/every resword is called. # # Reswords should not be used in bsdconfig itself (hence the name `reserved -# word') but instead only in scripts loaded through f_script_load()). +# word') but instead only in scripts loaded through f_script_load(). # f_resword_new() { local resword="$1" func="$2" [ "$resword" ] || return $FAILURE f_dprintf "script.subr: New resWord %s -> %s" "$resword" "$func" - eval $resword\(\){ f_dispatch $func $resword\; } + eval $resword\(\){ f_dispatch $func $resword \"\$@\"\; } RESWORDS="$RESWORDS${RESWORDS:+ }$resword" } -# f_dispatch $func [$resword] +# f_dispatch $func $resword # # Wrapper function used by `reserved words' (reswords) to call other functions. # If $noError is set and non-NULL, a failure result from $func is ignored, @@ -78,9 +76,10 @@ f_resword_new() # f_dispatch() { - local func="$1" resword="${2:-$1}" + local func="$1" resword="$2" + shift 2 # func resword f_dprintf "f_dispatch: calling resword \`%s'" "$resword" - eval $func + eval $func "$@" local retval=$? if [ $retval -ne $SUCCESS ]; then local _ignore_this_error