script.subr (245052) | script.subr (245695) |
---|---|
1if [ ! "$_SCRIPT_SUBR" ]; then _SCRIPT_SUBR=1 2# 3# Copyright (c) 2012 Devin Teske 4# All Rights Reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: --- 10 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# | 1if [ ! "$_SCRIPT_SUBR" ]; then _SCRIPT_SUBR=1 2# 3# Copyright (c) 2012 Devin Teske 4# All Rights Reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: --- 10 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# |
27# $FreeBSD: head/usr.sbin/bsdconfig/share/script.subr 245052 2013-01-05 02:08:47Z dteske $ | 27# $FreeBSD: head/usr.sbin/bsdconfig/share/script.subr 245695 2013-01-20 17:48:56Z dteske $ |
28# 29############################################################ INCLUDES 30 31BSDCFG_SHARE="/usr/share/bsdconfig" 32. $BSDCFG_SHARE/common.subr || exit 1 33f_dprintf "%s: loading includes..." script.subr 34f_include $BSDCFG_SHARE/variable.subr 35 --- 59 unchanged lines hidden (view full) --- 95# 96# Unknown/unregistered reswords will generate sh(1) syntax errors but not cause 97# premature termination. 98# 99# Returns success if a script was loaded and itself returned success. 100# 101f_script_load() 102{ | 28# 29############################################################ INCLUDES 30 31BSDCFG_SHARE="/usr/share/bsdconfig" 32. $BSDCFG_SHARE/common.subr || exit 1 33f_dprintf "%s: loading includes..." script.subr 34f_include $BSDCFG_SHARE/variable.subr 35 --- 59 unchanged lines hidden (view full) --- 95# 96# Unknown/unregistered reswords will generate sh(1) syntax errors but not cause 97# premature termination. 98# 99# Returns success if a script was loaded and itself returned success. 100# 101f_script_load() 102{ |
103 local script="$1" config_file | 103 local script="$1" config_file retval=$SUCCESS |
104 105 f_dprintf "f_script_load: script=[%s]" "$script" 106 if [ ! "$script" ]; then 107 f_getvar $VAR_CONFIG_FILE config_file 108 for script in \ 109 $config_file \ 110 install.cfg \ 111 /stand/install.cfg \ 112 /tmp/install.cfg \ 113 ; do 114 [ -e "$script" ] && break 115 done | 104 105 f_dprintf "f_script_load: script=[%s]" "$script" 106 if [ ! "$script" ]; then 107 f_getvar $VAR_CONFIG_FILE config_file 108 for script in \ 109 $config_file \ 110 install.cfg \ 111 /stand/install.cfg \ 112 /tmp/install.cfg \ 113 ; do 114 [ -e "$script" ] && break 115 done |
116 elif [ "$script" = "-" ]; then | 116 fi 117 118 local old_interactive= 119 f_getvar $VAR_NONINTERACTIVE old_interactive # save a copy 120 121 # Hint to others that we're running from a script, should they care 122 setvar $VAR_NONINTERACTIVE yes 123 124 if [ "$script" = "-" ]; then |
117 f_dprintf "f_script_load: Loading script from stdin" 118 eval "$( cat )" | 125 f_dprintf "f_script_load: Loading script from stdin" 126 eval "$( cat )" |
127 retval=$? |
|
119 else 120 f_dprintf "f_script_load: Loading script \`%s'" "$script" 121 if [ ! -e "$script" ]; then 122 f_show_msg "$msg_unable_to_open" "$script" 123 return $FAILURE 124 fi 125 . "$script" | 128 else 129 f_dprintf "f_script_load: Loading script \`%s'" "$script" 130 if [ ! -e "$script" ]; then 131 f_show_msg "$msg_unable_to_open" "$script" 132 return $FAILURE 133 fi 134 . "$script" |
135 retval=$? |
|
126 fi | 136 fi |
137 138 [ "$old_interactive" ] && 139 setvar $VAR_NONINTERACTIVE "$old_interactive" 140 141 return $retval |
|
127} 128 129############################################################ MAIN 130 131# 132# Reserved words meant for scripting 133# 134f_resword_new dumpVariables f_dump_variables 135f_resword_new loadConfig f_script_load 136 137f_dprintf "%s: Successfully loaded." script.subr 138 139fi # ! $_SCRIPT_SUBR | 142} 143 144############################################################ MAIN 145 146# 147# Reserved words meant for scripting 148# 149f_resword_new dumpVariables f_dump_variables 150f_resword_new loadConfig f_script_load 151 152f_dprintf "%s: Successfully loaded." script.subr 153 154fi # ! $_SCRIPT_SUBR |