From 2392a8bf9b0e9f5a731019a94893ddd0fdf120f1 Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Thu, 22 Aug 2019 21:46:06 +0300 Subject: [PATCH] Fix custom steps in Windows (fix #205) --- src/steps/generic.rs | 4 ++-- src/terminal.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/steps/generic.rs b/src/steps/generic.rs index bbddf6ed..7fe7798c 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -1,6 +1,6 @@ use crate::error::{Error, ErrorKind}; use crate::executor::{CommandExt, RunType}; -use crate::terminal::print_separator; +use crate::terminal::{print_separator, shell}; use crate::utils::{self, PathExt}; use directories::BaseDirs; use failure::ResultExt; @@ -110,7 +110,7 @@ pub fn run_myrepos_update(base_dirs: &BaseDirs, run_type: RunType) -> Result<(), pub fn run_custom_command(name: &str, command: &str, run_type: RunType) -> Result<(), Error> { print_separator(name); - run_type.execute("sh").arg("-c").arg(command).check_run() + run_type.execute(shell()).arg("-c").arg(command).check_run() } pub fn run_composer_update(base_dirs: &BaseDirs, run_type: RunType) -> Result<(), Error> { diff --git a/src/terminal.rs b/src/terminal.rs index d505a853..89566b3a 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -23,12 +23,12 @@ lazy_static! { } #[cfg(unix)] -fn shell() -> String { +pub fn shell() -> String { env::var("SHELL").unwrap_or_else(|_| "sh".to_string()) } #[cfg(windows)] -fn shell() -> &'static str { +pub fn shell() -> &'static str { which("pwsh").map(|_| "pwsh").unwrap_or("powershell") }