mirror of
https://github.com/uutils/coreutils
synced 2024-12-18 00:53:25 +00:00
Fixed empty backslash
Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.4326@gmail.com>
This commit is contained in:
parent
36c19293c8
commit
4fb4511da3
2 changed files with 21 additions and 2 deletions
|
@ -235,9 +235,20 @@ impl Sequence {
|
|||
(
|
||||
l,
|
||||
if let Some(input) = a.strip_prefix('\\') {
|
||||
char::from_u32(u32::from_str_radix(&input, 8).unwrap()).unwrap()
|
||||
if input.is_empty() {
|
||||
'\\'
|
||||
} else {
|
||||
char::from_u32(
|
||||
u32::from_str_radix(&input, 8)
|
||||
.expect("We only matched against 0-7 so it should not fail"),
|
||||
)
|
||||
.expect("Cannot convert octal value to character")
|
||||
}
|
||||
} else {
|
||||
input.chars().next().unwrap()
|
||||
input
|
||||
.chars()
|
||||
.next()
|
||||
.expect("We recognized a character so this should not fail")
|
||||
},
|
||||
)
|
||||
})
|
||||
|
|
|
@ -112,6 +112,14 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
|||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
if set2.len() == 1 && set2[0] == '\\' {
|
||||
show_error!(
|
||||
"{}",
|
||||
"warning: an unescaped backslash at end of string is not portable"
|
||||
);
|
||||
}
|
||||
|
||||
if delete_flag {
|
||||
if squeeze_flag {
|
||||
let mut delete_buffer = vec![];
|
||||
|
|
Loading…
Reference in a new issue