dsh-bash-native
dsh-bash-native: a Windows-native POSIX bash executor for the DSH shell seam, with engine resolution and DSH's three-tier file sandbox honored.
What it is
dsh-bash-native: a Windows-native POSIX bash executor for the DSH shell seam, with engine resolution and DSH's three-tier file sandbox honored.
How to install
Run this in the DSH web profile, then refresh the page.
$ dsh plugin --profile web add dsh-bash-native@0.3.3
DSH versions accepted
>=0.1.7-rc.2 <0.3.0-0
Author and traction
SpookyWaste · ★ 21 · Updated 2026-11-04
About this plugin
🐚 dsh-bash-native
Rust 实现的 Windows 原生 POSIX bash 执行器
给 DSH 的 shell 提供一个真正原生的 bash —— rubash 引擎,不依赖 WSL,也不需要 MSYS 兼容层
适配三档权限策略 · 后台作业 · 支持持久化终端
中文 · [English](README.en.md)
---
🐟 为什么需要它
> ~~避免肥鱼被 cmd 咬~~,也规避了子系统和 MSYS 兼容层的性能开销
0.3.1:引擎由brush更换为rubash,修复多项已知缺陷,提供更好的原生 POSIX 兼容
0.3.3:引擎升级到 rubash 1.5.0——三笔补丁 150-001–150-003,旧补丁随上游合入退役
方案
命令在哪里执行
每条命令的代价
Git for Windows
MSYS2 兼容层上的移植 bash,POSIX 语义由运行时模拟
兼容层每次起子 shell 或外部命令都要完整 fork 一个 MSYS2 进程(挂起线程、另起进程、经管道搬运内存),开销随子 shell 启动频率线性放大
WSL
命令在 Linux VM 的发行版里执行
每条命令都要经 Windows/Linux 边界往返一次,延迟对高频短命令尤为不利
本插件rubash 引擎 + 工具链
纯 Rust 实现的原生二进制,无模拟层、无 VM
grep、sed、awk 等来自随包工具链,其余由引擎在进程内处理,没有兼容层或 VM 边界
⚡ 实测:启动与子 shell 的代价
同一台机器(Windows 11 / x64)上的同一组脚本,每项取 5 次最小值,负载只用 shell 内建与一次外部进程,排除工具链差异。
> 复现:仓库里的 node scripts/bench-engines.mjs。
| 工作负载 | rubash(本插件) | Git Bash / MSYS2 |
|---|---:|---:|
| bash -c :(启动到退出) | 7 ms | 25 ms |
| echo hi | 6 ms | 26 ms |
| 算术循环 10k 次 | 65 ms | 75 ms |
| [ ] 判定 20k 次 | 167 ms | 181 ms |
| 命令替换 300 次 | 11 ms | 3052 ms |
| 子 shell 300 次 | 25 ms | 2497 ms |
| 外部进程 20 次(cmd /c exit) | 192 ms | 560 ms |
差距来自 fork:MSYS2 每次命令替换与子 shell 都要 fork 一个兼容层进程(约 8–10 ms),rubash 两样都做在进程内(每次约 0.04 ms),300 次就相差 2–3 秒。
🧭 路径不会被“自动替换”
Git Bash / MSYS2 把参数交给原生程序时会猜哪些像路径并改写(/flag → C:/Program Files/Git/flag,于是脚本和 agent 被迫记着 MSYS_NO_PATHCONV=1);连数据位也一起改:用 MSYS 调原生 awk.exe 跑 awk '/x/{print}',程序位到手是 X:/{print},直接语法错误、进错路径。
> rubash 不猜:按子进程方言,整条 argv 要么原样交给带 POSIX 层的程序,要么统一翻成 Win32 拼写;随包工具的脚本、模式、程序位永不改写,极大减少了找不到路径的情况。
---
📦 安装
CLI 安装
> 以 web profile 为例
dsh plugin --profile web add dsh-bash-native
dsh 网页版 / 桌面版安装
> dsh 插件页面 → 右上角 添加插件 → 填入插件名 dsh-bash-native 或仓库地址:
https://github.com/SpookyWaste/dsh-bash-native
重启后,在 Settings → General 里把 Native Bash (Windows) 设为默认 preset(或在会话里切过去)。
> 持久化终端组件默认关闭,在插件管理中可以打开。见[持久终端组件](#持久终端组件)。
平台
Windows x64
DSH
>=0.2.0-rc.2 <0.3.0-0(0.2.0-rc.2 - 0.2.1-rc.5实测)
持久终端组件
需要 DSH >=0.2.1-alpha.1才能开启
---
⚙️ 引擎
Compare in this category
The five most-starred plugins in the same category.
| Plugin | Author | Stars | Version | Updated |
|---|---|---|---|---|
| Mole | tw93 | 74.5K | 0.0.0 | 2026-11-10 |
| DeepSeek-Reasonix | esengine | 36.1K | 0.0.0 | 2026-11-10 |
| dsh-desktop | anywhere-labs | 35.6K | 0.4.1 | 2026-11-06 |
| awesome-dsh-plugin | awesome-dsh-plugin | 24.1K | 0.1.0 | 2026-11-10 |
| dsh-market | dsh-market | 11.8K | 1.73.17 | 2026-11-09 |