Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/uu/install/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ install-error-failed-to-remove = Failed to remove existing file { $path }. Error

# Warning messages
install-warning-compare-ignored = the --compare (-C) option is ignored when you specify a mode with non-permission bits
install-warning-no-strip-with-program = WARNING: ignoring --strip-program option as -s option was not specified

# Verbose output
install-verbose-creating-directory = creating directory { $path }
Expand Down
24 changes: 19 additions & 5 deletions src/uu/install/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,24 @@ fn behavior(matches: &ArgMatches) -> UResult<Behavior> {
let preserve_timestamps = matches.get_flag(OPT_PRESERVE_TIMESTAMPS);
let compare = matches.get_flag(OPT_COMPARE);
let strip = matches.get_flag(OPT_STRIP);
let strip_program = match matches.get_one::<String>(OPT_STRIP_PROGRAM) {
Some(p) => {
if !strip
&& writeln!(
std::io::stderr(),
"install: {}",
translate!("install-warning-no-strip-with-program")
)
.is_err()
{
uucore::error::set_exit_code(1);
}
p
}
None => DEFAULT_STRIP_PROGRAM,
}
.to_string();

if preserve_timestamps && compare {
show_error!(
"{}",
Expand Down Expand Up @@ -458,11 +476,7 @@ fn behavior(matches: &ArgMatches) -> UResult<Behavior> {
preserve_timestamps,
compare,
strip,
strip_program: String::from(
matches
.get_one::<String>(OPT_STRIP_PROGRAM)
.map_or(DEFAULT_STRIP_PROGRAM, |s| s.as_str()),
),
strip_program,
create_leading: matches.get_flag(OPT_CREATE_LEADING),
target_dir,
no_target_dir,
Expand Down
18 changes: 18 additions & 0 deletions tests/by-util/test_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,24 @@ fn test_install_and_strip() {
assert!(!stdout.contains(STRIP_SOURCE_FILE_SYMBOL));
}

#[test]
#[cfg(not(windows))]
#[cfg(not(target_os = "android"))] // missing strip binary
// FIXME test runs in a timeout with macos-latest on x86_64 in the CI
#[cfg(not(all(target_os = "macos", target_arch = "x86_64")))]
fn test_install_no_strip_with_program() {
TestScenario::new(util_name!())
.ucmd()
.arg("--strip-program")
.arg("true")
.arg(strip_source_file())
.arg(STRIP_TARGET_FILE)
.succeeds()
.stderr_only(
"install: WARNING: ignoring --strip-program option as -s option was not specified\n",
);
}

#[test]
#[cfg(not(windows))]
#[cfg(not(target_os = "android"))] // missing strip binary
Expand Down
Loading