mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-22 07:58:38 +08:00
parent
6a301381c8
commit
e2fdc63cdb
@ -1419,20 +1419,11 @@ pub fn read_blocked(fd: RawFd, buf: &mut [u8]) -> isize {
|
|||||||
|
|
||||||
/// Test if the string is a valid function name.
|
/// Test if the string is a valid function name.
|
||||||
pub fn valid_func_name(name: &wstr) -> bool {
|
pub fn valid_func_name(name: &wstr) -> bool {
|
||||||
if name.is_empty() {
|
!(name.is_empty()
|
||||||
return false;
|
|| name.starts_with('-')
|
||||||
};
|
|
||||||
if name.char_at(0) == '-' {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
// A function name needs to be a valid path, so no / and no NULL.
|
// A function name needs to be a valid path, so no / and no NULL.
|
||||||
if name.find_char('/').is_some() {
|
|| name.contains('/')
|
||||||
return false;
|
|| name.contains('\0'))
|
||||||
};
|
|
||||||
if name.find_char('\0').is_some() {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A rusty port of the C++ `write_loop()` function from `common.cpp`. This should be deprecated in
|
/// A rusty port of the C++ `write_loop()` function from `common.cpp`. This should be deprecated in
|
||||||
@ -1720,7 +1711,7 @@ fn get_executable_path(argv0: &str) -> PathBuf {
|
|||||||
/// the replacement value. Useful to avoid errors about multiple references (`&mut T` for `old` then
|
/// the replacement value. Useful to avoid errors about multiple references (`&mut T` for `old` then
|
||||||
/// `&T` again in the `new` expression).
|
/// `&T` again in the `new` expression).
|
||||||
pub fn replace_with<T, F: FnOnce(&T) -> T>(old: &mut T, with: F) -> T {
|
pub fn replace_with<T, F: FnOnce(&T) -> T>(old: &mut T, with: F) -> T {
|
||||||
let new = with(&*old);
|
let new = with(old);
|
||||||
std::mem::replace(old, new)
|
std::mem::replace(old, new)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user