Skip to content

Commit a47219b

Browse files
committed
true, false, echo: avoid uu_app().render_version() for smaller binary size
1 parent ff6dd99 commit a47219b

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/uu/echo/src/echo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
166166
uu_app().print_help()?;
167167
return Ok(());
168168
} else if first_arg == "--version" && args.peek().is_none() {
169-
write!(stdout(), "{}", uu_app().render_version())?;
169+
writeln!(stdout(), "echo {}", uucore::crate_version!())?;
170170
return Ok(());
171171
}
172172

@@ -186,7 +186,7 @@ pub fn uu_app() -> Command {
186186
// Note: echo is different from the other utils in that it should **not**
187187
// have `infer_long_args(true)`, because, for example, `--ver` should be
188188
// printed as `--ver` and not show the version text.
189-
Command::new(uucore::util_name())
189+
Command::new("echo")
190190
// TrailingVarArg specifies the final positional argument is a VarArg
191191
// and it doesn't attempts the parse any further args.
192192
// Final argument must have multiple(true) or the usage string equivalent.

src/uu/false/src/false.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ pub fn uumain(mut args: impl uucore::Args) -> i32 {
1616
let error = if flag == "--help" {
1717
uu_app().print_help()
1818
} else if flag == "--version" {
19-
write!(std::io::stdout(), "{}", uu_app().render_version())
19+
// avoid uu_app for smaller binary size
20+
writeln!(std::io::stdout(), "false {}", uucore::crate_version!())
2021
} else {
2122
return 1;
2223
};
@@ -30,7 +31,7 @@ pub fn uumain(mut args: impl uucore::Args) -> i32 {
3031
}
3132

3233
pub fn uu_app() -> Command {
33-
Command::new(uucore::util_name())
34+
Command::new("false")
3435
.version(uucore::crate_version!())
3536
.help_template(uucore::localized_help_template(uucore::util_name()))
3637
.about(translate!("false-about"))

src/uu/true/src/true.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ pub fn uumain(mut args: impl uucore::Args) -> i32 {
1616
let error = if flag == "--help" {
1717
uu_app().print_help()
1818
} else if flag == "--version" {
19-
write!(std::io::stdout(), "{}", uu_app().render_version())
19+
// avoid uu_app for smaller binary size
20+
writeln!(std::io::stdout(), "true {}", uucore::crate_version!())
2021
} else {
2122
return 0;
2223
};
@@ -35,7 +36,7 @@ pub fn uumain(mut args: impl uucore::Args) -> i32 {
3536
}
3637

3738
pub fn uu_app() -> Command {
38-
Command::new(uucore::util_name())
39+
Command::new("true")
3940
.version(uucore::crate_version!())
4041
.help_template(uucore::localized_help_template(uucore::util_name()))
4142
.about(translate!("true-about"))

0 commit comments

Comments
 (0)