Skip to content

Commit 62887c7

Browse files
zhitkoffsylvestre
authored andcommitted
split: directory separator in additional suffix
1 parent f05474a commit 62887c7

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/uu/split/src/filenames.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use crate::{
4040
};
4141
use clap::ArgMatches;
4242
use std::fmt;
43+
use std::path::is_separator;
4344
use uucore::display::Quotable;
4445
use uucore::error::{UResult, USimpleError};
4546

@@ -230,7 +231,7 @@ impl Suffix {
230231
.get_one::<String>(OPT_ADDITIONAL_SUFFIX)
231232
.unwrap()
232233
.to_string();
233-
if additional.contains('/') || additional.contains('\\') {
234+
if additional.chars().any(is_separator) {
234235
return Err(SuffixError::ContainsSeparator(additional));
235236
}
236237

tests/by-util/test_split.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,14 @@ fn test_split_additional_suffix() {
247247
}
248248

249249
#[test]
250-
fn test_additional_suffix_no_slash() {
250+
fn test_additional_suffix_dir_separator() {
251+
#[cfg(unix)]
251252
new_ucmd!()
252253
.args(&["--additional-suffix", "a/b"])
253254
.fails()
254255
.usage_error("invalid suffix 'a/b', contains directory separator");
256+
257+
#[cfg(windows)]
255258
new_ucmd!()
256259
.args(&["--additional-suffix", "a\\b"])
257260
.fails()

0 commit comments

Comments
 (0)