Skip to content
Open
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
21 changes: 1 addition & 20 deletions src/bin/coreutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use coreutils::validation;
use itertools::Itertools as _;
use std::cmp;
use std::ffi::OsString;
use std::io::{self, Write};
use std::process;
use uucore::Args;

Expand Down Expand Up @@ -106,26 +105,8 @@ fn main() {
process::exit(uumain(vec![util_os].into_iter().chain(args)));
}
None => {
// GNU coreutils --help string shows help for coreutils
if util == "--help" || util == "-h" {
// see if they want help on a specific util
if let Some(util_os) = args.next() {
let Some(util) = util_os.to_str() else {
validation::not_found(&util_os)
};

match utils.get(util) {
Some(&(uumain, _)) => {
let code = uumain(
vec![util_os, OsString::from("--help")]
.into_iter()
.chain(args),
);
io::stdout().flush().expect("could not flush stdout");
process::exit(code);
}
None => validation::not_found(&util_os),
}
}
usage(&utils, binary_as_util);
process::exit(0);
} else if util.starts_with('-') {
Expand Down
18 changes: 18 additions & 0 deletions tests/test_util_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ fn init() {
eprintln!("Setting UUTESTS_BINARY_PATH={TESTS_BINARY}");
}

#[test]
fn test_coreutils_help_ignore_args() {
use std::process::Command;

let scenario = TestScenario::new("help_ignoring_args");
if !scenario.bin_path.exists() {
return;
}

let output = Command::new(&scenario.bin_path)
.arg("--help")
.arg("---")
.output()
.unwrap();

assert_eq!(output.status.code(), Some(0));
}

#[test]
#[cfg(feature = "ls")]
fn execution_phrase_double() {
Expand Down
10 changes: 6 additions & 4 deletions util/fetch-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ repo=https://github.com/coreutils/coreutils
curl -L "${repo}/releases/download/v${ver}/coreutils-${ver}.tar.xz" | tar --strip-components=1 -xJf -

# TODO stop backporting tests from master at GNU coreutils > $ver
# backport = ()
# for f in ${backport[@]}
# do curl -L ${repo}/raw/refs/heads/master/tests/$f > tests/$f
# done
backport=(
misc/coreutils.sh
)
for f in "${backport[@]}"
do curl -L ${repo}/raw/refs/heads/master/tests/$f > tests/$f
done
Loading