Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions packages/electron-app/electron/main/user-shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,10 @@ function getDefaultShellPath(): string {
return "/bin/bash"
}

function wrapCommandForShell(command: string, shellPath: string): string {
const shellName = path.basename(shellPath)

if (shellName.includes("bash")) {
return 'if [ -f ~/.bashrc ]; then source ~/.bashrc >/dev/null 2>&1; fi; ' + command
}

if (shellName.includes("zsh")) {
return 'if [ -f ~/.zshrc ]; then source ~/.zshrc >/dev/null 2>&1; fi; ' + command
}

return command
}

function buildShellArgs(shellPath: string): string[] {
const shellName = path.basename(shellPath)
if (shellName.includes("zsh")) {
return ["-l", "-i", "-c"]
if (shellName.includes("zsh") || shellName.includes("bash")) {
return ["-i", "-l", "-c"]
}
return ["-l", "-c"]
}
Expand All @@ -59,12 +45,11 @@ export function buildUserShellCommand(userCommand: string): ShellCommand {
}

const shellPath = getDefaultShellPath()
const script = wrapCommandForShell(userCommand, shellPath)
const args = buildShellArgs(shellPath)

return {
command: shellPath,
args: [...args, script],
args: [...args, userCommand],
}
}

Expand Down
7 changes: 5 additions & 2 deletions packages/tauri-app/src-tauri/src/cli_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,8 +1288,11 @@ fn build_shell_args(shell: &str, command: &str) -> Vec<String> {
.unwrap_or("")
.to_lowercase();

let _ = shell_name;
vec!["-l".into(), "-c".into(), command.into()]
if shell_name.contains("zsh") || shell_name.contains("bash") {
vec!["-i".into(), "-l".into(), "-c".into(), command.into()]
} else {
vec!["-l".into(), "-c".into(), command.into()]
}
}

fn first_existing(paths: Vec<Option<PathBuf>>) -> Option<String> {
Expand Down
Loading