Don't use f_show_msg() unless printf(1) syntax is required (this reduces the

number of unnecessary forks).
This commit is contained in:
dteske 2013-01-14 21:03:34 +00:00
parent 3386d88ffd
commit 9bcfc5995d
14 changed files with 57 additions and 56 deletions

View File

@ -192,7 +192,7 @@ while :; do
err=$( ttys_set_type "$consterm" 2>&1 )
[ "$err" ] || break
f_show_msg "%s" "$err"
f_dialog_msgbox "$err"
done
exit $SUCCESS

View File

@ -72,7 +72,7 @@ f_mustberoot_init
if f_dialog_input_password; then
err=$( echo "$pw_password" | pw usermod $USER_ROOT -h 0 2>&1 ) ||
f_die $? "%s" "$err"
f_show_msg "$msg_password_changed"
f_dialog_msgbox "$msg_password_changed"
fi
return $SUCCESS

View File

@ -108,13 +108,13 @@ f_dialog_input_password()
# Check for NULL entry
if ! [ "$_password1" -o "$_password2" ]; then
f_show_msg "$msg_password_is_empty"
f_dialog_msgbox "$msg_password_is_empty"
continue
fi
# Check for password mismatch
if [ "$_password1" != "$_password2" ]; then
f_show_msg "$msg_passwords_do_not_match"
f_dialog_msgbox "$msg_passwords_do_not_match"
continue
fi

View File

@ -128,7 +128,7 @@ f_become_root_via_sudo()
1) # Always try sudo(8) when run as $user
local err
if ! err=$( touch "$checkpath" 2>&1 ); then
f_show_msg "%s" "$err"
f_dialog_msgbox "$err"
else
f_show_msg "$msg_created_path" "$checkpath"
fi

View File

@ -118,7 +118,7 @@ f_variable_set_defaults()
#
# Dump a list of registered/advertised variables and their respective values to
# $VARIABLE_DUMPFILE. Returns success unless the file couldn't be written. If
# an error occurs, it is displayed using f_show_msg() (from common.subr).
# an error occurs, it is displayed using f_dialog_msgbox() (from dialog.subr).
#
f_dump_variables()
{
@ -131,7 +131,7 @@ f_dump_variables()
printf "%s='%s'\n" "$var" "$value"
done > "$VARIABLE_DUMPFILE" ) 2>&1
); then
f_show_msg "%s" "$err"
f_dialog_msgbox "$err"
return $FAILURE
fi
}

View File

@ -307,14 +307,14 @@ while :; do
?" [X] "*) err=$( f_sysrc_set apm_enable NO 2>&1 ) ;;
?" [ ] "*) err=$( f_sysrc_set apm_enable YES 2>&1 ) ;;
esac
[ $? -eq $SUCCESS ] || f_show_msg "%s\n" "$err" ;;
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;;
?" ["?"] $msg_startup_dirs")
dialog_input_value \
"$msg_startup_dirs_desc" \
"$( f_sysrc_get local_startup )"
if [ $? -eq $SUCCESS ]; then
err=$( f_sysrc_set local_startup "$value" ) ||
f_show_msg "%s\n" "$err"
f_dialog_msgbox "$err\n"
fi
;;
?" ["?"] $msg_named")
@ -322,14 +322,14 @@ while :; do
?" [X] "*) err=$( f_sysrc_set named_enable NO 2>&1 ) ;;
?" [ ] "*) err=$( f_sysrc_set named_enable YES 2>&1 ) ;;
esac
[ $? -eq $SUCCESS ] || f_show_msg "%s\n" "$err" ;;
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;;
?" ["?"] $msg_named_flags")
dialog_input_value \
"$msg_named_flags_desc" \
"$( f_sysrc_get named_flags )"
if [ $? -eq $SUCCESS ]; then
err=$( f_sysrc_set named_flags "$value" ) ||
f_show_msg "%s\n" "$err"
f_dialog_msgbox "$err\n"
fi
;;
?" ["?"] $msg_nis_client")
@ -339,14 +339,14 @@ while :; do
err=$( f_sysrc_set nis_client_enable YES 2>&1 ) \
&& err=$( f_sysrc_set rpcbind_enable YES 2>&1 ) ;;
esac
[ $? -eq $SUCCESS ] || f_show_msg "%s\n" "$err" ;;
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;;
?" ["?"] $msg_nis_domainname")
dialog_input_value \
"$msg_nis_domainname_desc" \
"$( f_sysrc_get nisdomainname )"
if [ $? -eq $SUCCESS ]; then
err=$( f_sysrc_set nisdomainname "$value" ) ||
f_show_msg "%s\n" "$err"
f_dialog_msgbox "$err\n"
fi
;;
?" ["?"] $msg_nis_server")
@ -356,31 +356,31 @@ while :; do
err=$( f_sysrc_set nis_server_enable YES 2>&1 ) \
&& err=$( f_sysrc_set rpcbind_enable YES 2>&1 ) ;;
esac
[ $? -eq $SUCCESS ] || f_show_msg "%s\n" "$err" ;;
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;;
?" ["?"] $msg_accounting")
case "$mtag" in
?" [X] "*) err=$( f_sysrc_set accounting_enable NO 2>&1 ) ;;
?" [ ] "*) err=$( f_sysrc_set accounting_enable YES 2>&1 ) ;;
esac
[ $? -eq $SUCCESS ] || f_show_msg "%s\n" "$err" ;;
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;;
?" ["?"] $msg_lpd")
case "$mtag" in
?" [X] "*) err=$( f_sysrc_set lpd_enable NO 2>&1 ) ;;
?" [ ] "*) err=$( f_sysrc_set lpd_enable YES 2>&1 ) ;;
esac
[ $? -eq $SUCCESS ] || f_show_msg "%s\n" "$err" ;;
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;;
?" ["?"] $msg_sco")
case "$mtag" in
?" [X] "*) err=$( f_sysrc_set ibcs2_enable NO 2>&1 ) ;;
?" [ ] "*) err=$( f_sysrc_set ibcs2_enable YES 2>&1 ) ;;
esac
[ $? -eq $SUCCESS ] || f_show_msg "%s\n" "$err" ;;
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;;
?" ["?"] $msg_svr4")
case "$mtag" in
?" [X] "*) err=$( f_sysrc_set svr4_enable NO 2>&1 ) ;;
?" [ ] "*) err=$( f_sysrc_set svr4_enable YES 2>&1 ) ;;
esac
[ $? -eq $SUCCESS ] || f_show_msg "%s\n" "$err" ;;
[ $? -eq $SUCCESS ] || f_dialog_msgbox "$err\n" ;;
esac
done

View File

@ -318,7 +318,7 @@ while :; do
for var in $delete_vars; do
err=$( f_sysrc_delete $var 2>&1 )
if [ $? -ne $SUCCESS ]; then
f_show_msg "%s\n" "$err"
f_dialog_msgbox "$err\n"
break
fi
done

View File

@ -194,7 +194,7 @@ while :; do
esac
err=$( f_sysrc_set "$rcvar" "$value" 2>&1 ) ||
f_show_msg "$err"
f_dialog_msgbox "$err"
esac
done

View File

@ -432,14 +432,14 @@ f_dialog_input_rcvar()
# Check for invalid entry (1of2)
if ! echo "$_input" | grep -q "^[[:alpha:]_]"; then
f_show_msg "$msg_rcvar_must_start_with"
f_dialog_msgbox "$msg_rcvar_must_start_with"
continue
fi
# Check for invalid entry (2of2)
if ! echo "$_input" | grep -q "^[[:alpha:]_][[:alnum:]_]*$"
then
f_show_msg "$msg_rcvar_contains_invalid_chars"
f_dialog_msgbox "$msg_rcvar_contains_invalid_chars"
continue
fi

View File

@ -78,8 +78,7 @@ f_dialog_rcedit()
f_dprintf "%s: [%s]->[%s]" "$var" "$cur_val" "$_input"
err=$( f_sysrc_set "$var" "$_input" 2>&1 ) ||
f_show_msg "$err"
err=$( f_sysrc_set "$var" "$_input" 2>&1 ) || f_dialog_msgbox "$err"
}
############################################################ MAIN

View File

@ -63,10 +63,10 @@ save_changes()
err=$( pw groupdel "$group_name" 2>&1 )
retval=$?
if [ $retval -ne $SUCCESS ]; then
f_show_msg "%s %s\n" "$msg_error" "$err"
f_dialog_msgbox "$msg_error $err\n"
return $retval
fi
f_show_msg "$msg_group_deleted"
f_dialog_msgbox "$msg_group_deleted"
;;
Add)
local cmd="pw groupadd -n '$group_name'"
@ -82,10 +82,10 @@ save_changes()
err=$( eval $cmd 2>&1 )
retval=$?
if [ $retval -ne $SUCCESS ]; then
f_show_msg "%s %s\n" "$msg_error" "$err"
f_dialog_msgbox "$msg_error $err\n"
return $retval
fi
f_show_msg "$msg_group_added"
f_dialog_msgbox "$msg_group_added"
;;
Edit/View)
local cmd="pw groupmod -n '$group_name'"
@ -101,10 +101,10 @@ save_changes()
err=$( eval $cmd 2>&1 )
retval=$?
if [ $retval -ne $SUCCESS ]; then
f_show_msg "%s %s\n" "$msg_error" "$err"
f_dialog_msgbox "$msg_error $err\n"
return $retval
fi
f_show_msg "$msg_group_updated"
f_dialog_msgbox "$msg_group_updated"
;;
esac

View File

@ -134,13 +134,13 @@ f_dialog_input_group_name()
# Check for NULL entry
if [ ! "$_input" ]; then
f_show_msg "$msg_group_is_empty"
f_dialog_msgbox "$msg_group_is_empty"
continue
fi
# Check for invalid entry
if ! echo "$_input" | grep -q "^[[:alpha:]]"; then
f_show_msg "$msg_group_must_start_with_letter"
f_dialog_msgbox "$msg_group_must_start_with_letter"
continue
fi
@ -229,7 +229,7 @@ f_dialog_input_group_password()
# Check for password mismatch
if [ "$_password1" != "$_password2" ]; then
f_show_msg "$msg_group_passwords_do_not_match"
f_dialog_msgbox "$msg_group_passwords_do_not_match"
continue
fi

View File

@ -239,13 +239,13 @@ f_dialog_input_name()
# Check for NULL entry
if [ ! "$_input" ]; then
f_show_msg "$msg_login_is_empty"
f_dialog_msgbox "$msg_login_is_empty"
continue
fi
# Check for invalid entry
if ! echo "$_input" | grep -q "^[[:alpha:]]"; then
f_show_msg "$msg_login_must_start_with_letter"
f_dialog_msgbox "$msg_login_must_start_with_letter"
continue
fi
@ -334,7 +334,7 @@ f_dialog_input_password()
# Check for password mismatch
if [ "$_password1" != "$_password2" ]; then
f_show_msg "$msg_passwords_do_not_match"
f_dialog_msgbox "$msg_passwords_do_not_match"
continue
fi
@ -589,7 +589,7 @@ f_dialog_input_change()
# Taint-check the user's input
if ! f_isinteger "$ret_days"; then
f_show_msg "$msg_invalid_number_of_days"
f_dialog_msgbox "$msg_invalid_number_of_days"
continue
fi
@ -616,7 +616,8 @@ f_dialog_input_change()
# Taint-check the user's input
if ! f_isinteger "${_input:-0}"; then
f_show_msg "$msg_invalid_number_of_seconds"
f_dialog_msgbox \
"$msg_invalid_number_of_seconds"
continue
fi
@ -773,7 +774,7 @@ f_dialog_input_expire()
# Taint-check the user's input
if ! f_isinteger "$ret_days"; then
f_show_msg "$msg_invalid_number_of_days"
f_dialog_msgbox "$msg_invalid_number_of_days"
continue
fi
@ -800,7 +801,8 @@ f_dialog_input_expire()
# Taint-check the user's input
if ! f_isinteger "${_input:-0}"; then
f_show_msg "$msg_invalid_number_of_seconds"
f_dialog_msgbox \
"$msg_invalid_number_of_seconds"
continue
fi

View File

@ -81,22 +81,22 @@ save_changes()
err=$( pw userdel -u "$pw_uid" 2>&1 )
retval=$?
if [ $retval -ne $SUCCESS ]; then
f_show_msg "%s %s\n" "$msg_error" "$err"
f_dialog_msgbox "$msg_error $err\n"
return $retval
fi
f_show_msg "$msg_login_deleted"
f_dialog_msgbox "$msg_login_deleted"
if [ "$pw_group_delete" = "$msg_yes" ] &&
f_quietly pw groupshow -g "$pw_gid"
then
err=$( pw groupdel -g "$pw_gid" 2>&1 ) ||
f_show_msg "%s %s\n" "$msg_warning" "$err"
f_dialog_msgbox "$msg_warning $err\n"
fi
if [ "$pw_home_delete" = "$msg_yes" ]; then
f_dialog_info "$msg_deleting_home_directory"
err=$( rm -Rf "$pw_home_dir" 2>&1 ) ||
f_show_msg "%s %s\n" "$msg_warning" "$err"
f_dialog_msgbox "$msg_warning $err\n"
fi
;;
Add)
@ -119,26 +119,26 @@ save_changes()
err=$( eval $cmd 2>&1 )
retval=$?
if [ $retval -ne $SUCCESS ]; then
f_show_msg "%s %s\n" "$msg_error" "$err"
f_dialog_msgbox "$msg_error $err\n"
return $retval
fi
f_show_msg "$msg_login_added"
f_dialog_msgbox "$msg_login_added"
if [ "$pw_home_create" = "$msg_yes" ]; then
err=$( mkdir -p "$pw_home_dir" 2>&1 )
if [ $? -ne $SUCCESS ]; then
f_show_msg "%s %s\n" "$msg_warning" "$err"
f_dialog_msgbox "$msg_warning $err\n"
elif [ -e "$pw_home_dir" ]; then
err=$( chown -R "$pw_uid:$pw_gid" \
"$pw_home_dir" 2>&1 )
[ $? -eq $SUCCESS ] || f_show_msg \
"%s %s\n" "$msg_warning" "$err"
[ $? -eq $SUCCESS ] ||
f_dialog_msgbox "$msg_warning $err\n"
fi
fi
if [ "$pw_dotfiles_create" = "$msg_yes" ]; then
err=$( copy_dotfiles 2>&1 ) ||
f_show_msg "%s %s\n" "$msg_warning" "$err"
f_dialog_msgbox "$msg_warning $err\n"
fi
user="$pw_name"
@ -165,26 +165,26 @@ save_changes()
err=$( eval $cmd 2>&1 )
retval=$?
if [ $retval -ne $SUCCESS ]; then
f_show_msg "%s %s\n" "$msg_error" "$err"
f_dialog_msgbox "$msg_error $err\n"
return $retval
fi
f_show_msg "$msg_login_updated"
f_dialog_msgbox "$msg_login_updated"
if [ "$pw_home_create" = "$msg_yes" ]; then
err=$( mkdir -p "$pw_home_dir" )
if [ $? -ne $SUCCESS ]; then
f_show_msg "%s %s\n" "$msg_warning" "$err"
f_dialog_msgbox "$msg_warning $err\n"
elif [ -e "$pw_home_dir" ]; then
err=$( chown -R "$pw_uid:$pw_gid" \
"$pw_home_dir" 2>&1 )
[ $? -eq $SUCCESS ] || f_show_msg \
"%s %s\n" "$msg_warning" "$err"
[ $? -eq $SUCCESS ] ||
f_dialog_msgbox "$msg_warning $err\n"
fi
fi
if [ "$pw_dotfiles_create" = "$msg_yes" ]; then
err=$( copy_dotfiles 2>&1 ) ||
f_show_msg "%s %s\n" "$msg_warning" "$err"
f_dialog_msgbox "$msg_warning $err\n"
fi
;;
esac