mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 06:56:09 +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.
|
||||
pub fn valid_func_name(name: &wstr) -> bool {
|
||||
if name.is_empty() {
|
||||
return false;
|
||||
};
|
||||
if name.char_at(0) == '-' {
|
||||
return false;
|
||||
};
|
||||
!(name.is_empty()
|
||||
|| name.starts_with('-')
|
||||
// A function name needs to be a valid path, so no / and no NULL.
|
||||
if name.find_char('/').is_some() {
|
||||
return false;
|
||||
};
|
||||
if name.find_char('\0').is_some() {
|
||||
return false;
|
||||
};
|
||||
true
|
||||
|| name.contains('/')
|
||||
|| name.contains('\0'))
|
||||
}
|
||||
|
||||
/// 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
|
||||
/// `&T` again in the `new` expression).
|
||||
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)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user