Skip to content

Commit 99826e9

Browse files
committed
Use PowerShell as default shell on Windows & Fixes
* Use PowerShell as default on Windows if available to match behavior on Windows terminal. * Fix Linting after update to rust 1.92
1 parent e9e0da3 commit 99826e9

File tree

7 files changed

+54
-2
lines changed

7 files changed

+54
-2
lines changed

application/apps/indexer/addons/shell-tools/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ fn load_shells() -> Vec<ShellProfile> {
4242
shells
4343
}
4444

45+
#[cfg(windows)]
46+
/// Provides the path of built-in PowerShell on Windows, calculating it
47+
/// only on the very first call.
48+
pub fn get_win_powershell() -> Option<&'static std::path::PathBuf> {
49+
use std::{path::PathBuf, sync::OnceLock};
50+
static PATH: OnceLock<Option<PathBuf>> = std::sync::OnceLock::new();
51+
PATH.get_or_init(|| which::which_global("powershell").ok())
52+
.as_ref()
53+
}
54+
4555
fn is_path_valid(shell: ShellType, path: &Path) -> bool {
4656
match shell {
4757
ShellType::Bash

application/apps/indexer/processor/src/search/error.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::grabber::GrabError;
2-
use log::error;
32
use serde::Serialize;
43
use thiserror::Error;
54

application/apps/indexer/session/src/tail/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Include functionalities for tailing files to send notifications once new
22
//! data are written to the file.
33
4-
use log::error;
54
use std::path::Path;
65
use thiserror::Error as ThisError;
76
use tokio::{

application/apps/indexer/sources/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ regex.workspace = true
2828
shellexpand = "3.1"
2929
stypes = { path = "../stypes", features=["rustcore"] }
3030
socket2 = "0.5.8"
31+
shell-tools = { path = "../addons/shell-tools" }
3132

3233
[dev-dependencies]
3334
env_logger.workspace = true

application/apps/indexer/sources/src/command/process.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ impl ProcessSource {
4949

5050
let (bin, cmd_arg) = shell
5151
.map(|sh| (sh.path.as_os_str().to_os_string(), sh.shell.command_arg()))
52+
// Check if built-in PowerShell is installed in use it as default shell.
53+
.or_else(|| {
54+
shell_tools::get_win_powershell().map(|p| {
55+
(
56+
p.as_os_str().to_os_string(),
57+
stypes::ShellType::Pwsh.command_arg(),
58+
)
59+
})
60+
})
5261
.unwrap_or_else(|| (OsString::from("cmd"), "/C"));
5362

5463
Command::new(bin)

application/apps/rustcore/rs-bindings/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/chipmunk-cli/Cargo.lock

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)