mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 07:13:44 +08:00
fix: use replace instead
This commit is contained in:
parent
438106f42e
commit
5de0e58d5d
@ -15,7 +15,8 @@ pub fn grant_permission(core: String) -> anyhow::Result<()> {
|
|||||||
let output = {
|
let output = {
|
||||||
// the path of clash /Applications/Clash Verge.app/Contents/MacOS/clash
|
// the path of clash /Applications/Clash Verge.app/Contents/MacOS/clash
|
||||||
// https://apple.stackexchange.com/questions/82967/problem-with-empty-spaces-when-executing-shell-commands-in-applescript
|
// https://apple.stackexchange.com/questions/82967/problem-with-empty-spaces-when-executing-shell-commands-in-applescript
|
||||||
let path = escape(&path);
|
// let path = escape(&path);
|
||||||
|
let path = path.replace(' ', "\\\\ ");
|
||||||
let shell = format!("chown root:admin {path}\nchmod +sx {path}");
|
let shell = format!("chown root:admin {path}\nchmod +sx {path}");
|
||||||
let command = format!(r#"do shell script "{shell}" with administrator privileges"#);
|
let command = format!(r#"do shell script "{shell}" with administrator privileges"#);
|
||||||
Command::new("osascript")
|
Command::new("osascript")
|
||||||
@ -42,6 +43,7 @@ pub fn grant_permission(core: String) -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
pub fn escape<'a>(text: &'a str) -> Cow<'a, str> {
|
pub fn escape<'a>(text: &'a str) -> Cow<'a, str> {
|
||||||
let bytes = text.as_bytes();
|
let bytes = text.as_bytes();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user