Closed james-cook closed 1 year ago
Related to #458: When --equal is passed, rm_cmd_parse_equal
gets called before rm_cmd_set_outputs
, so the rm_fmt_clear
call is ineffective.
lib/cmdline.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/cmdline.c b/lib/cmdline.c
index 49c81627..b3b884c5 100644
--- a/lib/cmdline.c
+++ b/lib/cmdline.c
@@ -1060,6 +1060,10 @@ static bool rm_cmd_set_paths(RmSession *session, char **paths) {
}
static bool rm_cmd_set_outputs(RmSession *session, GError **error) {
+ if(session->cfg->run_equal_mode) {
+ return true;
+ }
+
if(session->output_cnt[0] >= 0 && session->output_cnt[1] >= 0) {
g_set_error(error, RM_ERROR_QUARK, 0,
_("Specifying both -o and -O is not allowed"));
I haven't tested this patch but it should work around the issue. The correct fix would be to have dedicated option parsing for --equal, just like --is-reflink and --dedupe - I disagree with the conclusion in #483 that it is fine as-is, because although it uses the main "shredder" code, it should only allow a narrow subset of options because of its specific purpose.
I haven't had a chance to test this yet.
Just to restate in case it gets forgotten: As mentioned (https://github.com/sahib/rmlint/issues/553) the problem is that the running rmlint.sh can currently overwrite itself as it is executing - and this can in fact change what is being executed leading to unexpected results
Calling
sudo ./rmlint.sh -px
A directory compare takes place for example if paranoid mode is selected.The resulting call to rmlint (the command not the script) overwrites the rmlint.sh and rmlint.json despite -x being specified
This can be a little disconcerting