File tree 1 file changed +15
-24
lines changed
1 file changed +15
-24
lines changed Original file line number Diff line number Diff line change @@ -919,30 +919,21 @@ easytls_config ()
919
919
# Update config
920
920
config_update ()
921
921
{
922
- # Find the pattern
923
- " ${EASYTLS_GREP} " -q " ^${cfg_opt} [[:blank:]]=[[:blank:]].*$" \
924
- " ${EASYTLS_CONFIG_FILE} " || {
925
- error_msg " config_update - input error: ${cfg_opt} "
926
- return 1
927
- }
928
-
929
- # backup
930
- " ${EASYTLS_CP} " " ${EASYTLS_CONFIG_FILE} " " ${EASYTLS_CONFIG_FILE} .tmp" || {
931
- error_msg " config_update - backup"
922
+ # remove old_record
923
+ old_record=" ^${cfg_opt} = .*\$ "
924
+ if universal_update del " ${EASYTLS_CONFIG_FILE} " " ${old_record} " ; then
925
+ : # ok
926
+ else
932
927
return 1
933
- }
934
-
935
- # Replace the pattern
936
- [ " ${cfg_val} " != " 0" ] || unset -v cfg_val
937
- " ${EASYTLS_SED} " -i -e \
938
- " s\` ^${cfg_opt} [[:blank:]]=[[:blank:]].*$\` ${cfg_opt} = ${cfg_val} \` g" \
939
- " ${EASYTLS_CONFIG_FILE} " || {
940
- error_msg " config_update - replace error: ${cfg_opt} "
941
- return 1
942
- }
928
+ fi
943
929
944
- # cleanup
945
- " ${EASYTLS_RM} " -f " ${EASYTLS_CONFIG_FILE} .tmp"
930
+ # add new_record
931
+ new_record=" ${cfg_opt} = ${cfg_val} "
932
+ if universal_update add " ${EASYTLS_CONFIG_FILE} " " ${new_record} " ; then
933
+ : # ok
934
+ else
935
+ return 1
936
+ fi
946
937
947
938
easytls_verbose
948
939
easytls_verbose " config-file updated: ${cfg_opt} = ${cfg_val} "
@@ -6399,9 +6390,9 @@ universal_update ()
6399
6390
fi
6400
6391
;;
6401
6392
del)
6402
- if " ${EASYTLS_GREP} " -q " ^ ${record} " " ${EASYTLS_TEMP_LIST} " ; then
6393
+ if " ${EASYTLS_GREP} " -q " ${record} " " ${EASYTLS_TEMP_LIST} " ; then
6403
6394
# Delete record
6404
- if " ${EASYTLS_SED} " -e " /^ ${record} /d" \
6395
+ if " ${EASYTLS_SED} " -e " /${record} /d" \
6405
6396
" ${EASYTLS_TEMP_LIST} " > " ${EASYTLS_TEMP_UPDATE} "
6406
6397
then
6407
6398
# Success
You can’t perform that action at this time.
0 commit comments