PowerShell integration breaks existing PSConsoleHostReadline
评估
调研方向
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 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/coreutils 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 3/5 1-2 天 新手友好度 55/100
-
难度 4/5 3-5 天 新手友好度 30/100
-
难度 3/5 半天 新手友好度 50/100
查看 microsoft/coreutils 的全部 Issue
相似的 Issue
-
area: library data-loss type: bug
难度 2/5 1-3 小时 新手友好度 72/100
alplabai/signex#1740 · 1 条评论 ·
维护者通常 1 天内回复
-
test(fslc): the unreadable mutate catalog test pins the Unix I/O error text and fails on Windows可能已有人在做 @rizumita 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 69/100
维护者通常 1 天内回复
-
ServerProperties defaults white-list to true, so a fresh --dedicated server silently locks itself未关闭
难度 2/5 1-3 小时 新手友好度 78/100
horizon-rust/horizon#3888 ·
维护者通常 1 天内回复
-
refactor
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复