Skip to content

Commit 1a0576d

Browse files
committed
replace funky control flow with something more conventional
1 parent 9cc02ef commit 1a0576d

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/visudo/mod.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ fn edit_sudoers_file(
278278
)
279279
})?;
280280

281-
let true = errors.is_empty() else {
281+
if !errors.is_empty() {
282282
writeln!(stderr, "The provided sudoers file format is not recognized or contains syntax errors. Please review:\n")?;
283283

284284
for crate::sudoers::Error {
@@ -297,24 +297,24 @@ fn edit_sudoers_file(
297297
b'x' => return Ok(()),
298298
_ => continue,
299299
}
300-
};
301-
302-
if sudo_visudo_is_allowed(sudoers, &host_name) == Some(false) {
303-
writeln!(
304-
stderr,
305-
"It looks like you have removed your ability to run 'sudo visudo' again.\n"
306-
)?;
307-
match ask_response(
308-
b"What now? e(x)it without saving / (e)dit again / lock me out and (S)ave: ",
309-
b"xeS",
310-
)? {
311-
b'x' => return Ok(()),
312-
b'S' => {}
313-
_ => continue,
300+
} else {
301+
if sudo_visudo_is_allowed(sudoers, &host_name) == Some(false) {
302+
writeln!(
303+
stderr,
304+
"It looks like you have removed your ability to run 'sudo visudo' again.\n"
305+
)?;
306+
match ask_response(
307+
b"What now? e(x)it without saving / (e)dit again / lock me out and (S)ave: ",
308+
b"xeS",
309+
)? {
310+
b'x' => return Ok(()),
311+
b'S' => {}
312+
_ => continue,
313+
}
314314
}
315-
}
316315

317-
break;
316+
break;
317+
}
318318
}
319319

320320
let tmp_contents = std::fs::read(tmp_path)?;

0 commit comments

Comments
 (0)