script.subr (262895) | script.subr (262900) |
---|---|
1if [ ! "$_SCRIPT_SUBR" ]; then _SCRIPT_SUBR=1 2# 3# Copyright (c) 2012-2014 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 (INCLUDING, 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-2014 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 (INCLUDING, 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 262895 2014-03-07 20:12:59Z dteske $ | 27# $FreeBSD: head/usr.sbin/bsdconfig/share/script.subr 262900 2014-03-07 20:24:59Z 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/device.subr 35f_include $BSDCFG_SHARE/media/any.subr --- 54 unchanged lines hidden (view full) --- 90 unset $VAR_NO_ERROR 91} 92 93# f_script_load [$file] 94# 95# Load a script (usually filled with reswords). If $file is missing or NULL, 96# use one of the following instead (in order): 97# | 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/device.subr 35f_include $BSDCFG_SHARE/media/any.subr --- 54 unchanged lines hidden (view full) --- 90 unset $VAR_NO_ERROR 91} 92 93# f_script_load [$file] 94# 95# Load a script (usually filled with reswords). If $file is missing or NULL, 96# use one of the following instead (in order): 97# |
98# $configFile | 98# $configFile (global) |
99# install.cfg 100# /stand/install.fg 101# /tmp/install.cfg 102# 103# Unknown/unregistered reswords will generate sh(1) syntax errors but not cause 104# premature termination. 105# 106# Returns success if a script was loaded and itself returned success. 107# 108f_script_load() 109{ | 99# install.cfg 100# /stand/install.fg 101# /tmp/install.cfg 102# 103# Unknown/unregistered reswords will generate sh(1) syntax errors but not cause 104# premature termination. 105# 106# Returns success if a script was loaded and itself returned success. 107# 108f_script_load() 109{ |
110 local funcname=f_script_load |
|
110 local script="$1" config_file retval=$SUCCESS 111 | 111 local script="$1" config_file retval=$SUCCESS 112 |
112 f_dprintf "f_script_load: script=[%s]" "$script" | 113 f_dprintf "$funcname: script=[%s]" "$script" |
113 if [ ! "$script" ]; then 114 f_getvar $VAR_CONFIG_FILE config_file 115 for script in \ 116 $config_file \ 117 install.cfg \ 118 /stand/install.cfg \ 119 /tmp/install.cfg \ 120 ; do 121 [ -e "$script" ] && break 122 done 123 fi 124 125 local old_interactive= 126 f_getvar $VAR_NONINTERACTIVE old_interactive # save a copy 127 128 # Hint to others that we're running from a script, should they care 129 setvar $VAR_NONINTERACTIVE yes 130 131 if [ "$script" = "-" ]; then | 114 if [ ! "$script" ]; then 115 f_getvar $VAR_CONFIG_FILE config_file 116 for script in \ 117 $config_file \ 118 install.cfg \ 119 /stand/install.cfg \ 120 /tmp/install.cfg \ 121 ; do 122 [ -e "$script" ] && break 123 done 124 fi 125 126 local old_interactive= 127 f_getvar $VAR_NONINTERACTIVE old_interactive # save a copy 128 129 # Hint to others that we're running from a script, should they care 130 setvar $VAR_NONINTERACTIVE yes 131 132 if [ "$script" = "-" ]; then |
132 f_dprintf "f_script_load: Loading script from stdin" | 133 f_dprintf "$funcname: Loading script from stdin" |
133 eval "$( cat )" 134 retval=$? 135 else | 134 eval "$( cat )" 135 retval=$? 136 else |
136 f_dprintf "f_script_load: Loading script \`%s'" "$script" | 137 f_dprintf "$funcname: Loading script \`%s'" "$script" |
137 if [ ! -e "$script" ]; then 138 f_show_msg "$msg_unable_to_open" "$script" 139 return $FAILURE 140 fi 141 . "$script" 142 retval=$? 143 fi 144 --- 62 unchanged lines hidden --- | 138 if [ ! -e "$script" ]; then 139 f_show_msg "$msg_unable_to_open" "$script" 140 return $FAILURE 141 fi 142 . "$script" 143 retval=$? 144 fi 145 --- 62 unchanged lines hidden --- |