Reverse SVN r240770 -- jilles@ made a suggestion that allowed us to redesign

our embedded rescue environment to support /dev/null making r240770 obsolete.

Reviewed by:	jilles, adrian (co-mentor)
Approved by:	jilles, adrian (co-mentor)
This commit is contained in:
Devin Teske 2012-09-21 19:03:25 +00:00
parent 777813c555
commit fb7d723e6b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=240783
22 changed files with 62 additions and 62 deletions

View File

@ -73,7 +73,7 @@ usage()
# Determine the maximum width of terminal/console
#
local max_size max_width
max_size=$( stty size 2>&- )
max_size=$( stty size 2> /dev/null )
: ${max_size:="24 80"}
max_width="${max_size#*[$IFS]}"
f_dprintf "max_width=[$max_width]"
@ -242,8 +242,8 @@ if [ "$1" ]; then
#
lang="${LANG:-$LC_ALL}"
if [ "$lang" ]; then
sel=$( grep "^menu_selection=\"$1|" */INDEX.$lang 2>&- |
tail -1 )
sel=$( grep "^menu_selection=\"$1|" */INDEX.$lang \
2> /dev/null | tail -1 )
# Fall-back to non-i18n sources if nothing was found
[ "$sel" ] ||

View File

@ -117,8 +117,8 @@ ttys_set_type()
# with 0600 permissions -- change the permissions and ownership to
# match ttys(5) before we write it out and mv(1) it into place).
#
local mode="$( stat -f '%#Lp' "$ETC_TTYS" 2>&- )"
local owner="$( stat -f '%u:%g' "$ETC_TTYS" 2>&- )"
local mode="$( stat -f '%#Lp' "$ETC_TTYS" 2> /dev/null )"
local owner="$( stat -f '%u:%g' "$ETC_TTYS" 2> /dev/null )"
f_quietly chmod "${mode:-0644}" "$tmpfile"
f_quietly chown "${owner:-root:wheel}" "$tmpfile"

View File

@ -86,7 +86,7 @@ flags=$( f_sysrc_get moused_flags )
#
f_dialog_info "$msg_trying_to_start_the_mouse_daemon"
[ -r "$MOUSED_PIDFILE" ] &&
f_quietly kill "$( cat "$MOUSED_PIDFILE" 2>&- )"
f_quietly kill "$( cat "$MOUSED_PIDFILE" 2> /dev/null )"
f_quietly vidcontrol -m on
f_quietly moused -t "$type" -p "$port" $flags

View File

@ -112,7 +112,7 @@ while :; do
# configuration
#
dhcp=
eval "$( exec 2>&-
eval "$( exec 2> /dev/null
set -- $_ifconfig
while [ $# -gt 0 ]; do
case "$1" in

View File

@ -72,7 +72,7 @@ f_device_desc()
devname="${device%%$d*}"
devunit="${device#$devname}"
devunit="${devunit%%[a-zA-Z_]*}"
sysctl -n "dev.$devname.$devunit.%desc" 2>&- &&
sysctl -n "dev.$devname.$devunit.%desc" 2> /dev/null &&
return $SUCCESS
fi

View File

@ -47,7 +47,7 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
f_ifconfig_inet()
{
local interface="$1"
ifconfig "$interface" 2>&- | awk \
ifconfig "$interface" 2> /dev/null | awk \
'
BEGIN { found = 0 }
( $1 == "inet" ) \

View File

@ -83,7 +83,7 @@ f_ifconfig_options()
f_ifconfig_media()
{
local interface="$1"
ifconfig -m "$interface" 2>&- | awk \
ifconfig -m "$interface" 2> /dev/null | awk \
'
BEGIN { media_found = 0 }
{

View File

@ -46,7 +46,7 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
f_ifconfig_netmask()
{
local interface="$1" octets
octets=$( ifconfig "$interface" 2>&- | awk \
octets=$( ifconfig "$interface" 2> /dev/null | awk \
'
BEGIN { found = 0 }
( $1 == "inet" ) \

View File

@ -65,7 +65,7 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
#
f_resolv_conf_domain()
{
tail -r "$RESOLV_CONF" 2>&- | awk \
tail -r "$RESOLV_CONF" 2> /dev/null | awk \
'
BEGIN { found = 0 }
( tolower($1) == "domain" ) \
@ -84,7 +84,7 @@ f_resolv_conf_domain()
#
f_resolv_conf_search()
{
tail -r "$RESOLV_CONF" 2>&- | awk \
tail -r "$RESOLV_CONF" 2> /dev/null | awk \
'
BEGIN { found = 0 }
{
@ -118,7 +118,7 @@ f_resolv_conf_nameservers()
}
END { exit ! found }
' \
"$RESOLV_CONF" 2>&-
"$RESOLV_CONF" 2> /dev/null
}
# f_dialog_resolv_conf_update $hostname
@ -225,8 +225,8 @@ f_dialog_resolv_conf_update()
# permissions and ownership to match resolv.conf(5) before
# we write it out and mv(1) it into place).
#
local mode="$( stat -f '%#Lp' "$RESOLV_CONF" 2>&- )"
local owner="$( stat -f '%u:%g' "$RESOLV_CONF" 2>&- )"
local mode="$( stat -f '%#Lp' "$RESOLV_CONF" 2> /dev/null )"
local owner="$( stat -f '%u:%g' "$RESOLV_CONF" 2> /dev/null )"
f_quietly chmod "${mode:-0644}" "$tmpfile"
f_quietly chown "${owner:-root:wheel}" "$tmpfile"
@ -246,7 +246,7 @@ f_dialog_resolv_conf_update()
#
local domain="${hostname#*.}" new_contents
[ "$domain" = "$hostname" ] && domain=
new_contents=$( tail -r "$RESOLV_CONF" 2>&- )
new_contents=$( tail -r "$RESOLV_CONF" 2> /dev/null )
new_contents=$( echo "$new_contents" | awk \
-v domain="$domain" \
-v search_all="${RESOLVER_SEARCH_DOMAINS_ALL:-1}" \
@ -397,8 +397,8 @@ f_dialog_input_nameserver()
# Quietly fixup permissions and ownership
#
local mode owner
mode=$( stat -f '%#Lp' "$RESOLV_CONF" 2>&- )
owner=$( stat -f '%u:%g' "$RESOLV_CONF" 2>&- )
mode=$( stat -f '%#Lp' "$RESOLV_CONF" 2> /dev/null )
owner=$( stat -f '%u:%g' "$RESOLV_CONF" 2> /dev/null )
f_quietly chmod "${mode:-0644}" "$tmpfile"
f_quietly chown "${owner:-root:wheel}" "$tmpfile"

View File

@ -46,7 +46,7 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
#
f_route_get_default()
{
route -n get default 2>&- | awk \
route -n get default 2> /dev/null | awk \
'
BEGIN { found = 0 }
( $1 == "gateway:" ) \

View File

@ -72,7 +72,7 @@ f_err()
#
f_quietly()
{
"$@" >&- 2>&-
"$@" > /dev/null 2>&1
}
# f_have $anything ...

View File

@ -1321,7 +1321,7 @@ f_dialog_init()
# Process stored command-line arguments
#
SECURE=$( set -- "$ARGV"
while getopts S flag >&-; do
while getopts S flag > /dev/null; do
case "$flag" in
S) echo 1;;
\?) continue;;
@ -1329,7 +1329,7 @@ f_dialog_init()
done
)
USE_XDIALOG=$( set -- "$ARGV"
while getopts SX flag >&-; do
while getopts SX flag > /dev/null; do
case "$flag" in
S|X) echo 1;;
\?) continue;;
@ -1372,7 +1372,7 @@ f_dialog_init()
eval xauth -if \~$SUDO_USER/.Xauthority extract - \
\"\$HOSTNAME/unix:\$displaynum\" \
\"\$HOSTNAME:\$displaynum\" | sudo sh -c 'xauth -ivf \
~root/.Xauthority merge - >&- 2>&-'
~root/.Xauthority merge - > /dev/null 2>&1'
fi
#

View File

@ -85,7 +85,7 @@ f_become_root_via_sudo()
#
# Check sudo(8) access before prompting for password.
#
:| sudo -S -v 2>&-
:| sudo -S -v 2> /dev/null
if [ $? -ne $SUCCESS ]; then
#
# sudo(8) access denied. Prompt for their password.
@ -112,7 +112,7 @@ f_become_root_via_sudo()
--ok-label "$msg_ok" \
--cancel-label "$msg_cancel" \
--password --inputbox "$msg" $size \
2>&1 >&- )
2>&1 > /dev/null )
retval=$?
# Catch X11-related errors
@ -141,7 +141,7 @@ f_become_root_via_sudo()
#
# Validate sudo(8) credentials
#
sudo -S -v 2>&- <<-EOF
sudo -S -v 2> /dev/null <<-EOF
$password
EOF
retval=$?
@ -186,7 +186,7 @@ f_become_root_via_sudo()
displaynum="${DISPLAY#*:}"
xauth -f ~/.Xauthority extract - $HOSTNAME/unix:$displaynum \
$HOSTNAME:$displaynum | sudo sh -c 'xauth -ivf \
~root/.Xauthority merge - >&- 2>&-'
~root/.Xauthority merge - > /dev/null 2>&1'
fi
# Re-execute ourselves with sudo(8)
@ -254,7 +254,7 @@ f_authenticate_some_user()
$height $width \
"$field_username" "" \
"$field_password" "" \
2>&1 >&- )
2>&1 > /dev/null )
retval=$?
# Catch X11-related errors
@ -302,7 +302,7 @@ f_authenticate_some_user()
su -m "$user" <<-EOF
sh <<EOS
sudo -k
sudo -S -v 2>&- <<EOP
sudo -S -v 2> /dev/null <<EOP
$password
EOP
EOS

View File

@ -98,7 +98,7 @@ f_isinteger()
# Attempt to perform arithmetic divison (an operation which will exit
# with error unless arg is a valid positive/negative whole integer).
#
( : $((0/$arg)) ) >&- 2>&-
( : $((0/$arg)) ) > /dev/null 2>&1
}
fi # ! $_STRINGS_SUBR

View File

@ -134,7 +134,7 @@ f_sysrc_get()
#
f_clean_env --except RC_CONFS RC_DEFAULTS SUCCESS
. "$RC_DEFAULTS" >&- 2>&-
. "$RC_DEFAULTS" > /dev/null 2>&1
unset RC_DEFAULTS
# no longer needed
@ -153,7 +153,7 @@ f_sysrc_get()
# If RC_CONFS is defined, set $rc_conf_files to an explicit
# value, modifying the default behavior of source_rc_confs().
#
( : ${RC_CONFS?} ) >&- 2>&-
( : ${RC_CONFS?} ) > /dev/null 2>&1
if [ $? -eq ${SUCCESS:-0} ]; then
rc_conf_files="$RC_CONFS"
_rc_confs_set=1
@ -162,7 +162,7 @@ f_sysrc_get()
unset SUCCESS
# no longer needed
source_rc_confs >&- 2>&-
source_rc_confs > /dev/null 2>&1
#
# If the query was for `rc_conf_files' AND after calling
@ -190,7 +190,7 @@ f_sysrc_get()
# such as "${varname?}" and "${varname:?}" (see "Parameter
# Expansion" in sh(1) for more information).
#
eval echo '"${'"$1"'}"' 2>&-
eval echo '"${'"$1"'}"' 2> /dev/null
)
}
@ -221,7 +221,7 @@ f_sysrc_get_default()
#
f_clean_env --except RC_DEFAULTS
. "$RC_DEFAULTS" >&- 2>&-
. "$RC_DEFAULTS" > /dev/null 2>&1
unset RC_DEFAULTS
# no longer needed
@ -232,7 +232,7 @@ f_sysrc_get_default()
# such as "${varname?}" and "${varname:?}" (see "Parameter
# Expansion" in sh(1) for more information).
#
eval echo '"${'"$1"'}"' 2>&-
eval echo '"${'"$1"'}"' 2> /dev/null
)
}
@ -477,7 +477,7 @@ f_sysrc_set()
# permissions from the temporary file).
#
local mode
mode=$( stat -f '%#Lp' "$file" 2>&- )
mode=$( stat -f '%#Lp' "$file" 2> /dev/null )
f_quietly chmod "${mode:-0644}" "$tmpfile"
#
@ -486,14 +486,14 @@ f_sysrc_set()
# permissions (so we throw stderr into the bit-bucket).
#
local owner
owner=$( stat -f '%u:%g' "$file" 2>&- )
owner=$( stat -f '%u:%g' "$file" 2> /dev/null )
f_quietly chown "${owner:-root:wheel}" "$tmpfile"
#
# Operate on the matching file, replacing only the last occurrence.
#
local new_contents retval
new_contents=$( tail -r $file 2>&- )
new_contents=$( tail -r $file 2> /dev/null )
new_contents=$( echo "$new_contents" | awk -v varname="$varname" \
-v new_value="$new_value" "$f_sysrc_set_awk" )
retval=$?
@ -572,8 +572,8 @@ f_sysrc_delete()
# permissions) to instead match the destination file.
#
local mode owner
mode=$( stat -f '%#Lp' "$file" 2>&- )
owner=$( stat -f '%u:%g' "$file" 2>&- )
mode=$( stat -f '%#Lp' "$file" 2> /dev/null )
owner=$( stat -f '%u:%g' "$file" 2> /dev/null )
f_quietly chmod "${mode:-0644}" "$tmpfile"
f_quietly chown "${owner:-root:wheel}" "$tmpfile"

View File

@ -46,7 +46,7 @@ ipgm=$( f_index_menu_selection $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
# Options
#
# Inherit SHOW_DESC value if set, otherwise default to 1
( : ${SHOW_DESC?} ) >&- 2>&- || SHOW_DESC=1
( : ${SHOW_DESC?} ) > /dev/null 2>&1 || SHOW_DESC=1
############################################################ FUNCTIONS

View File

@ -54,7 +54,7 @@ RCCONF_MENU_LIST=
# Options
#
# Inherit SHOW_DESC value if set, otherwise default to 1
( : ${SHOW_DESC?} ) >&- 2>&- || SHOW_DESC=1
( : ${SHOW_DESC?} ) > /dev/null 2>&1 || SHOW_DESC=1
# Selectively inherit SHOW_* value (in order of preference)
if [ "$SHOW_DEFAULT_VALUE" ]; then
SHOW_DEFAULT_VALUE=1
@ -110,8 +110,8 @@ dialog_menu_main()
f_dialog_info "$msg_creating_menu_list"
RCCONF_MENU_LIST="$RCCONF_MENU_LIST $(
. "$RC_DEFAULTS" >&-
source_rc_confs >&-
. "$RC_DEFAULTS" > /dev/null
source_rc_confs > /dev/null
var_list=$( f_startup_rcconf_list )
for var in $var_list; do
eval export $var

View File

@ -54,7 +54,7 @@ RCCONF_MENU_LIST=
# Options
#
# Inherit SHOW_DESC value if set, otherwise default to 1
( : ${SHOW_DESC?} ) >&- 2>&- || SHOW_DESC=1
( : ${SHOW_DESC?} ) > /dev/null 2>&1 || SHOW_DESC=1
# Selectively inherit SHOW_* value (in order of preference)
if [ "$SHOW_DEFAULT_VALUE" ]; then
SHOW_DEFAULT_VALUE=1
@ -112,8 +112,8 @@ dialog_menu_main()
f_dialog_info "$msg_creating_menu_list"
RCCONF_MENU_LIST="$RCCONF_MENU_LIST $(
. "$RC_DEFAULTS" >&-
source_rc_confs >&-
. "$RC_DEFAULTS" > /dev/null
source_rc_confs > /dev/null
var_list=$( f_startup_rcconf_list )
for var in $var_list; do
eval export $var
@ -348,7 +348,7 @@ while :; do
var="${mtag# }"
# Toggle the state-variable and loop back to menu
if ( eval : \${_${var}_delete?} ) >&- 2>&-; then
if ( eval : \${_${var}_delete?} ) > /dev/null 2>&1; then
unset _${var}_delete
else
setvar _${var}_delete 1

View File

@ -54,7 +54,7 @@ RCVAR_MENU_LIST=
# Options
#
# Inherit SHOW_DESC value if set, otherwise default to 1
( ${SHOW_DESC?} ) >&- 2>&- || SHOW_DESC=1
( ${SHOW_DESC?} ) > /dev/null 2>&1 || SHOW_DESC=1
############################################################ FUNCTIONS
@ -82,8 +82,8 @@ dialog_menu_main()
fi
RCVAR_MENU_LIST="$RCVAR_MENU_LIST $(
. "$RC_DEFAULTS" >&-
source_rc_confs >&-
. "$RC_DEFAULTS" > /dev/null
source_rc_confs > /dev/null
for rcvar in $( echo "$RCVAR_MAP" | awk '{print $1}' ); do
eval export $rcvar
done

View File

@ -63,9 +63,9 @@ STARTUP_RCCONF_MAP_CACHEFILE="/var/run/bsdconfig/startup_rcconf_map.cache"
f_startup_rcconf_list()
{
( # Operate within a sub-shell to protect the parent environment
. "$RC_DEFAULTS" >&-
. "$RC_DEFAULTS" > /dev/null
f_clean_env --except PATH STARTUP_RCCONF_REGEX rc_conf_files
source_rc_confs >&-
source_rc_confs > /dev/null
export _rc_conf_files_file="$( f_sysrc_find rc_conf_files )"
export RC_DEFAULTS
set | awk -F= "

View File

@ -610,7 +610,7 @@ f_install_zoneinfo()
# Save knowledge for later
if [ "$REALLYDOIT" -a $rv -eq $SUCCESS ]; then
if : 2>&- > "$_PATH_DB"; then
if : 2> /dev/null > "$_PATH_DB"; then
cat <<-EOF > "$_PATH_DB"
$zoneinfo
EOF

View File

@ -627,7 +627,7 @@ f_dialog_input_change()
local secs="$_input"
{ f_isinteger "$secs" && [ $secs -gt 0 ]; } || secs=
_input_date=$( date -j -f "%s" -- "$secs" \
"+%d %m %Y" 2>&- )
"+%d %m %Y" 2> /dev/null )
calendar_size=$( f_dialog_calendar_size \
"$DIALOG_TITLE" \
"$DIALOG_BACKTITLE" \
@ -654,7 +654,7 @@ f_dialog_input_change()
_input_time=
[ "$secs" ] && _input_time=$( date -j \
-f %s -- "$_input" "+%H %M %S" 2>&- )
-f %s -- "$_input" "+%H %M %S" 2> /dev/null )
timebox_size=$( f_dialog_timebox_size \
"$DIALOG_TITLE" \
"$DIALOG_BACKTITLE" \
@ -682,7 +682,7 @@ f_dialog_input_change()
_input=$( date \
-j -f "%d/%m/%Y %T" \
-- "$ret_date $ret_time" \
+%s 2>&- )
+%s 2> /dev/null )
f_dprintf "_input=[$_input]"
break ;;
@ -852,7 +852,7 @@ f_dialog_input_expire()
local secs="$_input"
{ f_isinteger "$secs" && [ $secs -gt 0 ]; } || secs=
_input_date=$( date -j -f "%s" -- "$secs" \
"+%d %m %Y" 2>&- )
"+%d %m %Y" 2> /dev/null )
calendar_size=$( f_dialog_calendar_size \
"$DIALOG_TITLE" \
"$DIALOG_BACKTITLE" \
@ -879,7 +879,7 @@ f_dialog_input_expire()
_input_time=
[ "$secs" ] && _input_time=$( date -j \
-f %s -- "$_input" "+%H %M %S" 2>&- )
-f %s -- "$_input" "+%H %M %S" 2> /dev/null )
timebox_size=$( f_dialog_timebox_size \
"$DIALOG_TITLE" \
"$DIALOG_BACKTITLE" \
@ -906,7 +906,7 @@ f_dialog_input_expire()
_input=$( date \
-j -f "%d/%m/%Y %T" \
-- "$ret_date $ret_time" \
+%s 2>&- )
+%s 2> /dev/null )
f_dprintf "_input=[$_input]"
break ;;