Skip to content

Commit

Permalink
fix: use replace instead
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzgydi committed Mar 17, 2023
1 parent fc5ca96 commit 533dc99
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src-tauri/src/core/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ pub fn grant_permission(core: String) -> anyhow::Result<()> {
let output = {
// 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
let path = escape(&path);
// let path = escape(&path);
let path = path.replace(' ', "\\\\ ");
let shell = format!("chown root:admin {path}\nchmod +sx {path}");
let command = format!(r#"do shell script "{shell}" with administrator privileges"#);
Command::new("osascript")
Expand All @@ -42,6 +43,7 @@ pub fn grant_permission(core: String) -> anyhow::Result<()> {
}
}

#[allow(unused)]
pub fn escape<'a>(text: &'a str) -> Cow<'a, str> {
let bytes = text.as_bytes();

Expand Down

0 comments on commit 533dc99

Please sign in to comment.