Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

PowerShell integration breaks existing PSConsoleHostReadline

未关闭
#190 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@markovejnovic 已经在做这个了。

开始于 2026年10月27日。

  • #194 来自 @markovejnovic —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
powershell, rust
领域
cli

调研方向

Start with src/pwsh-install-template.ps1, especially the PSConsoleHostReadLine definition linked in the issue, and review how it reads and rewrites commands. Reproduce the conflict with Atuin or another existing readline handler in a PowerShell session. Done when the previous handler is called and command history records the faithful command while coreutils commands still work.

由索引模型根据 Issue 内容生成。

描述

Hey! I'm an engineer at Atuin and a user filed a report describing that Atuin doesn't appear to be compatible with this project at https://github.com/atuinsh/atuin/issues/4386. Atuin is a program that records your shell command history.

It seems that the user's issue is because you override PSConsoleHostReadline in https://github.com/microsoft/coreutils/blob/8a56d6fc1e5a36116c245781cb3758ebe758bb9a/src/pwsh-install-template.ps1#L80.

We also override PSConsoleHostReadline, and since coreutils is defined last, coreutils' implementation of PSConsoleHostReadline wins, which prevents ours from being called.

I had the idea of calling your PSConsoleHostReadline in Atuin's PS1 files and then passing that down our handler:

if (!$script:__ATUIN_PREV_READLINE__) {
    $script:__ATUIN_PREV_READLINE__ = $Function:PSConsoleHostReadLine
}

function PSConsoleHostReadLine {
    $line = & $script:__ATUIN_PREV_READLINE__
    # ...

But that unfortunately doesn't capture history accurately since you use PSConsoleHostReadline to rewrite the command:

ls        -> & 'C:\Program Files\coreutils\cmd\ls.cmd' --color=auto
ls -la    -> & 'C:\Program Files\coreutils\cmd\ls.cmd' --color=auto -la

I'd suspect that atuin is perhaps not the only program which overrides PSConsoleHostReadline. I'd appreciate if you implemented the fix I attempted to implement in Atuin. I think it's relatively reasonable for you to assume that the result of PSConsoleHostReadline from any other programs will be a "faithful" command you can straight up run. Something like this:

+if (!$script:__COREUTILS_PREV_READLINE__) {
+    $script:__COREUTILS_PREV_READLINE__ = $Function:PSConsoleHostReadLine
+}
 function PSConsoleHostReadLine {
     [System.Diagnostics.DebuggerHidden()]
     param()

-    $lastRunStatus = $?
+    # Must stay the first statement: the previous handler reads $? itself.
+    $line = & $script:__COREUTILS_PREV_READLINE__
     Microsoft.PowerShell.Core\Set-StrictMode -Off
-    $line = [Microsoft.PowerShell.PSConsoleReadLine]::ReadLine($host.Runspace, $ExecutionContext, $lastRunStatus)

I'm setting up a Windows VM and I'll open a PR when I have that ready.

主要语言
Rust
星标
5.3k
派生
110
平均合并
1 小时 26 分钟
30 天内合并 PR
3

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/coreutils 的其他 Issue

查看 microsoft/coreutils 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。