mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
od: fix command-line parsing of file names
This commit is contained in:
+3
-4
@@ -134,12 +134,11 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
||||
}
|
||||
};
|
||||
|
||||
// Gather up file names - args which don't start with '-'
|
||||
let mut inputs = args[1..]
|
||||
// Gather up file names
|
||||
let mut inputs = matches.free
|
||||
.iter()
|
||||
.filter_map(|w| match w as &str {
|
||||
"--" => Some(InputSource::Stdin),
|
||||
o if o.starts_with("-") => None,
|
||||
"-" => Some(InputSource::Stdin),
|
||||
x => Some(InputSource::FileName(x)),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
minus lowercase f
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
lowercase c
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
lowercase x
|
||||
+17
-1
@@ -117,7 +117,7 @@ fn test_from_mixed() {
|
||||
}
|
||||
}
|
||||
|
||||
let result = new_ucmd!().arg("--endian=little").arg(file1.as_os_str()).arg("--").arg(file3.as_os_str()).run_piped_stdin(data2.as_bytes());
|
||||
let result = new_ucmd!().arg("--endian=little").arg(file1.as_os_str()).arg("-").arg(file3.as_os_str()).run_piped_stdin(data2.as_bytes());
|
||||
|
||||
assert_empty_stderr!(result);
|
||||
assert!(result.success);
|
||||
@@ -548,3 +548,19 @@ fn test_ascii_dump(){
|
||||
0000026
|
||||
"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_filename_parsing(){
|
||||
// files "a" and "x" both exists, but are no filenames in the commandline below
|
||||
// "-f" must be treated as a filename, it contains the text: minus lowercase f
|
||||
// so "-f" should not be interpreted as a formatting option.
|
||||
let result = new_ucmd!().arg("--format").arg("a").arg("-A").arg("x").arg("--").arg("-f").run();
|
||||
|
||||
assert_empty_stderr!(result);
|
||||
assert!(result.success);
|
||||
assert_eq!(result.stdout, unindent("
|
||||
000000 m i n u s sp l o w e r c a s e sp
|
||||
000010 f nl
|
||||
000012
|
||||
"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user