svn commit: r262895 - in head/usr.sbin/bsdconfig: . share
Devin Teske
dteske at FreeBSD.org
Fri Mar 7 20:13:00 UTC 2014
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
More information about the svn-src-all
mailing list