Skip to content

Commit 13df9e2

Browse files
committed
echo: remove double negation
1 parent b0fa702 commit 13df9e2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/uu/echo/src/echo.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
282282
// "If the POSIXLY_CORRECT environment variable is set, then when echo’s first argument is not -n it outputs option-like arguments instead of treating them as options."
283283
// https://www.gnu.org/software/coreutils/manual/html_node/echo-invocation.html
284284

285-
let no_newline = matches.get_flag(options::NO_NEWLINE);
285+
let trailing_newline = !matches.get_flag(options::NO_NEWLINE);
286286
let escaped = matches.get_flag(options::ENABLE_BACKSLASH_ESCAPE);
287287

288288
let mut stdout_lock = io::stdout().lock();
@@ -291,14 +291,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
291291
Some(arguments_after_options) => {
292292
execute(
293293
&mut stdout_lock,
294-
no_newline,
294+
trailing_newline,
295295
escaped,
296296
arguments_after_options,
297297
)?;
298298
}
299299
None => {
300300
// No strings to print, so just handle newline setting
301-
if !no_newline {
301+
if trailing_newline {
302302
stdout_lock.write_all(b"\n")?;
303303
}
304304
}
@@ -350,7 +350,7 @@ pub fn uu_app() -> Command {
350350

351351
fn execute(
352352
stdout_lock: &mut StdoutLock,
353-
no_newline: bool,
353+
trailing_newline: bool,
354354
escaped: bool,
355355
arguments_after_options: ValuesRef<'_, OsString>,
356356
) -> UResult<()> {
@@ -375,7 +375,7 @@ fn execute(
375375
}
376376
}
377377

378-
if !no_newline {
378+
if trailing_newline {
379379
stdout_lock.write_all(b"\n")?;
380380
}
381381

0 commit comments

Comments
 (0)