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

number of unnecessary forks).
This commit is contained in:
Devin Teske 2013-01-14 21:03:34 +00:00
parent 3258649e41
commit db7b0ba78f
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=$( ttys_set_type "$consterm" 2>&1 )
[ "$err" ] || break [ "$err" ] || break
f_show_msg "%s" "$err" f_dialog_msgbox "$err"
done done
exit $SUCCESS exit $SUCCESS

View File

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

View File

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

View File

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

View File

@ -118,7 +118,7 @@ f_variable_set_defaults()
# #
# Dump a list of registered/advertised variables and their respective values to # Dump a list of registered/advertised variables and their respective values to
# $VARIABLE_DUMPFILE. Returns success unless the file couldn't be written. If # $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() f_dump_variables()
{ {
@ -131,7 +131,7 @@ f_dump_variables()
printf "%s='%s'\n" "$var" "$value" printf "%s='%s'\n" "$var" "$value"
done > "$VARIABLE_DUMPFILE" ) 2>&1 done > "$VARIABLE_DUMPFILE" ) 2>&1
); then ); then
f_show_msg "%s" "$err" f_dialog_msgbox "$err"
return $FAILURE return $FAILURE
fi fi
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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