Skip to content

Commit

Permalink
Fix: default answers set to default instead of unset
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-arch committed Dec 23, 2024
1 parent f4e211f commit d42c77a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
16 changes: 16 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d42c77a

Please sign in to comment.