From d42c77aef650cddec01f65390326920aa26459ac Mon Sep 17 00:00:00 2001 From: leo-arch Date: Mon, 23 Dec 2024 01:24:53 -0300 Subject: [PATCH] Fix: default answers set to default instead of unset --- src/config.c | 16 ++++++++++++++++ src/init.c | 12 ++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/config.c b/src/config.c index ae62b21d..24434ff1 100644 --- a/src/config.c +++ b/src/config.c @@ -3092,6 +3092,17 @@ set_rl_edit_mode(const char *val) rl_emacs_editing_mode(1, 0); } +static void +set_default_answers_to_default(void) +{ + conf.default_answer.remove = DEF_ANSWER_REMOVE; + conf.default_answer.trash = DEF_ANSWER_TRASH; + conf.default_answer.bulk_rename = DEF_ANSWER_BULK_RENAME; + conf.default_answer.overwrite = DEF_ANSWER_OVERWRITE; + conf.default_answer.default_ = DEF_ANSWER_DEFAULT; + conf.default_answer.default_all = DEF_ANSWER_DEFAULT_ALL; +} + /* Read the main configuration file and set options accordingly */ static void read_config(void) @@ -3109,6 +3120,7 @@ read_config(void) if (xargs.rl_vi_mode == 1) rl_vi_editing_mode(1, 0); + int default_answers_set = 0; int ret = -1; conf.max_name_len = DEF_MAX_NAME_LEN; *div_line = *DEF_DIV_LINE; @@ -3204,6 +3216,7 @@ read_config(void) } else if (*line == 'D' && strncmp(line, "DefaultAnswer=", 14) == 0) { + default_answers_set = 1; set_default_answers(line + 14); } @@ -3602,6 +3615,9 @@ read_config(void) fclose(config_fp); + if (default_answers_set == 0) + set_default_answers_to_default(); + if (xargs.disk_usage_analyzer == 1) { conf.sort = STSIZE; conf.long_view = conf.full_dir_size = 1; diff --git a/src/init.c b/src/init.c index 29dbe6be..d05ea830 100644 --- a/src/init.c +++ b/src/init.c @@ -192,12 +192,12 @@ init_conf_struct(void) conf.color_lnk_as_target = UNSET; conf.columned = DEF_COLUMNS; conf.cp_cmd = DEF_CP_CMD; - conf.default_answer.remove = DEF_ANSWER_REMOVE; - conf.default_answer.trash = DEF_ANSWER_TRASH; - conf.default_answer.bulk_rename = DEF_ANSWER_BULK_RENAME; - conf.default_answer.overwrite = DEF_ANSWER_OVERWRITE; - conf.default_answer.default_ = DEF_ANSWER_DEFAULT; - conf.default_answer.default_all = DEF_ANSWER_DEFAULT_ALL; + conf.default_answer.remove = 0; + conf.default_answer.trash = 0; + conf.default_answer.bulk_rename = 0; + conf.default_answer.overwrite = 0; + conf.default_answer.default_ = 0; + conf.default_answer.default_all = 0; conf.desktop_notifications = UNSET; conf.dirhist_map = UNSET; conf.disk_usage = UNSET;