Skip to content

Commit 8cff520

Browse files
committed
Start deprecating dangerous -h/-V aliases
1 parent ff6dd99 commit 8cff520

3 files changed

Lines changed: 18 additions & 19 deletions

File tree

docs/src/extensions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ $ ls -w=80
2323
```
2424

2525
With GNU coreutils, `--help` usually prints the help message and `--version` prints the version.
26-
We also commonly provide short options: `-h` for help and `-V` for version.
26+
We also have short aliases for them: `-h` for help and `-V` for version for few utils. But we deprecate them since it cause confusion at some cases e.g. `sort -h`.
2727

2828
## `coreutils`
2929

src/bin/coreutils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn main() {
7777
match util {
7878
"--list" => {
7979
// If --help is also present, show usage instead of list
80-
if args.any(|arg| arg == "--help" || arg == "-h") {
80+
if args.any(|arg| arg == "--help") {
8181
usage(&utils, binary_as_util);
8282
process::exit(0);
8383
}
@@ -87,7 +87,7 @@ fn main() {
8787
}
8888
process::exit(0);
8989
}
90-
"--version" | "-V" => {
90+
"--version" => {
9191
println!("{binary_as_util} {VERSION} (multi-call binary)");
9292
process::exit(0);
9393
}
@@ -106,7 +106,7 @@ fn main() {
106106
process::exit(uumain(vec![util_os].into_iter().chain(args)));
107107
}
108108
None => {
109-
if util == "--help" || util == "-h" {
109+
if util == "--help" {
110110
// see if they want help on a specific util
111111
if let Some(util_os) = args.next() {
112112
let Some(util) = util_os.to_str() else {

tests/test_util_name.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -192,21 +192,20 @@ fn util_version() {
192192
println!("Skipping test: Binary not found at {:?}", scenario.bin_path);
193193
return;
194194
}
195-
for arg in ["-V", "--version"] {
196-
let child = Command::new(&scenario.bin_path)
197-
.arg(arg)
198-
.stdin(Stdio::piped())
199-
.stdout(Stdio::piped())
200-
.stderr(Stdio::piped())
201-
.spawn()
202-
.unwrap();
203-
let output = child.wait_with_output().unwrap();
204-
assert_eq!(output.status.code(), Some(0));
205-
assert_eq!(output.stderr, b"");
206-
let output_str = String::from_utf8(output.stdout).unwrap();
207-
let ver = env::var("CARGO_PKG_VERSION").unwrap();
208-
assert_eq!(format!("coreutils {ver} (multi-call binary)\n"), output_str);
209-
}
195+
196+
let child = Command::new(&scenario.bin_path)
197+
.arg("--version")
198+
.stdin(Stdio::piped())
199+
.stdout(Stdio::piped())
200+
.stderr(Stdio::piped())
201+
.spawn()
202+
.unwrap();
203+
let output = child.wait_with_output().unwrap();
204+
assert_eq!(output.status.code(), Some(0));
205+
assert_eq!(output.stderr, b"");
206+
let output_str = String::from_utf8(output.stdout).unwrap();
207+
let ver = env::var("CARGO_PKG_VERSION").unwrap();
208+
assert_eq!(format!("coreutils {ver} (multi-call binary)\n"), output_str);
210209
}
211210

212211
#[test]

0 commit comments

Comments
 (0)