diff --git a/src/mv.c b/src/mv.c
index 1d1ddda..ccdde75 100644
--- a/src/mv.c
+++ b/src/mv.c
@@ -98,7 +98,7 @@ rm_option_init (struct rm_options *x)
/* Should we prompt for removal, too? No. Prompting for the `move'
part is enough. It implies removal. */
- x->interactive = RMI_NEVER;
+ x->interactive = change(RMI_OLD_FALSE, RMI_NEVER);
x->stdin_tty = false;
x->verbose = false;
diff --git a/src/remove.c b/src/remove.c
index 97184eb..c93802c 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -148,6 +148,7 @@ struct dirstack_state
};
typedef struct dirstack_state Dirstack_state;
+
/* Like fstatat, but cache the result. If ST->st_size is -1, the
status has not been gotten yet. If less than -1, fstatat failed
with errno == -1 - ST->st_size. Otherwise, the status has already
@@ -798,14 +799,14 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename,
*is_empty = T_UNKNOWN;
- if (x->interactive == RMI_NEVER)
+ if (change(0, x->interactive == RMI_NEVER))
return RM_OK;
- if (((!x->ignore_missing_files & ((x->interactive == RMI_ALWAYS)
+ if (((!x->ignore_missing_files & ((change(x->interactive == RMI_OLD_TRUE, x->interactive == RMI_ALWAYS))
| x->stdin_tty))
&& (write_protected = write_protected_non_symlink (fd_cwd, filename,
ds, sbuf)))
- || x->interactive == RMI_ALWAYS)
+ || change(x->interactive == RMI_OLD_TRUE, x->interactive == RMI_ALWAYS))
{
if (cache_fstatat (fd_cwd, filename, sbuf, AT_SYMLINK_NOFOLLOW) != 0)
{
@@ -825,7 +826,8 @@ prompt (int fd_cwd, Dirstack_state const *ds, char const *filename,
/* Using permissions doesn't make sense for symlinks. */
if (S_ISLNK (sbuf->st_mode))
{
- if (x->interactive != RMI_ALWAYS)
+ // changing (!x->interactive) to (x->interactive == 0)
+ if (change(x->interactive == RMI_OLD_FALSE, x->interactive != RMI_ALWAYS))
return RM_OK;
write_protected = false;
}
diff --git a/src/remove.h b/src/remove.h
index ae01e3c..74644fa 100644
--- a/src/remove.h
+++ b/src/remove.h
@@ -26,6 +26,12 @@ enum rm_interactive
{
/* Start with any number larger than 1, so that any legacy tests
against values of 0 or 1 will fail. */
+
+ // interactive's type changed from bool to enum type rm_interactive
+ // Hence adding true and false to the enum for compatibility with the old version
+ RMI_OLD_FALSE = 0,
+ RMI_OLD_TRUE = 1,
+
RMI_ALWAYS = 3,
RMI_SOMETIMES,
RMI_NEVER
diff --git a/src/rm.c b/src/rm.c
index 81f81ec..20bb1a8 100644
--- a/src/rm.c
+++ b/src/rm.c
@@ -213,7 +213,8 @@ static void
rm_option_init (struct rm_options *x)
{
x->ignore_missing_files = false;
- x->interactive = RMI_SOMETIMES;
+ // changing false in old version to 0, corresponding to RMI_OLD_FALSE in enum rm_interactive
+ x->interactive = change(RMI_OLD_FALSE, RMI_SOMETIMES);
x->one_file_system = false;
x->recursive = false;
x->root_dev_ino = NULL;
@@ -255,19 +256,23 @@ main (int argc, char **argv)
break;
case 'f':
- x.interactive = RMI_NEVER;
+ // Changing false in old version to 0, corresponding to RMI_OLD_FALSE in enum rm_interactive
+ x.interactive = change(RMI_OLD_FALSE, RMI_NEVER);
x.ignore_missing_files = true;
prompt_once = false;
break;
case 'i':
- x.interactive = RMI_ALWAYS;
+ // Changing true in old version to 1, corresponding to RMI_OLD_TRUE in enum rm_interactive
+ x.interactive = change(RMI_OLD_TRUE, RMI_ALWAYS);
x.ignore_missing_files = false;
prompt_once = false;
break;
case 'I':
- x.interactive = RMI_NEVER;
+ // Changing false in old version to 0, corresponding to RMI_OLD_FALSE in enum rm_interactive
+ // Basically, false in old version is now handled by RMI_NEVER and RMI_SOMETIMES
+ x.interactive = change(RMI_OLD_FALSE, RMI_NEVER);
x.ignore_missing_files = false;
prompt_once = true;
break;
@@ -288,18 +293,18 @@ main (int argc, char **argv)
switch (i)
{
case interactive_never:
- x.interactive = RMI_NEVER;
+ x.interactive = change(RMI_OLD_FALSE, RMI_NEVER);
prompt_once = false;
break;
case interactive_once:
- x.interactive = RMI_SOMETIMES;
+ x.interactive = change(RMI_OLD_FALSE, RMI_SOMETIMES);
x.ignore_missing_files = false;
prompt_once = true;
break;
case interactive_always:
- x.interactive = RMI_ALWAYS;
+ x.interactive = change(RMI_OLD_TRUE, RMI_ALWAYS);
x.ignore_missing_files = false;
prompt_once = false;
break;