diff options
author | dteske <dteske@FreeBSD.org> | 2014-03-07 20:12:59 +0000 |
---|---|---|
committer | dteske <dteske@FreeBSD.org> | 2014-03-07 20:12:59 +0000 |
commit | fa3a5f9350058062c93858db3317a916462f3a3f (patch) | |
tree | 8076f634b7c8f22d0270a358fbe838ac54ea3898 | |
parent | 10361d66d0d438166a585c00112aa5d9fcf658cf (diff) | |
download | FreeBSD-src-fa3a5f9350058062c93858db3317a916462f3a3f.zip FreeBSD-src-fa3a5f9350058062c93858db3317a916462f3a3f.tar.gz |
Allow dispatched reswords to carry arguments. Fix a comment while here.
-rwxr-xr-x | usr.sbin/bsdconfig/bsdconfig | 2 | ||||
-rw-r--r-- | usr.sbin/bsdconfig/share/script.subr | 15 |
2 files changed, 8 insertions, 9 deletions
diff --git a/usr.sbin/bsdconfig/bsdconfig b/usr.sbin/bsdconfig/bsdconfig index c158bfa..cc7bd2c 100755 --- a/usr.sbin/bsdconfig/bsdconfig +++ b/usr.sbin/bsdconfig/bsdconfig @@ -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 diff --git a/usr.sbin/bsdconfig/share/script.subr b/usr.sbin/bsdconfig/share/script.subr index a227419..8e55b09 100644 --- a/usr.sbin/bsdconfig/share/script.subr +++ b/usr.sbin/bsdconfig/share/script.subr @@ -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 |