Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

PowerShell integration breaks existing PSConsoleHostReadline

Ouverte
#190 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

@markovejnovic y travaille déjà.

Depuis le 27/10/2026.

  • #194 par @markovejnovic — ouverte

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
55/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
powershell, rust
Domaine
cli

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Rust
Étoiles
5.3k
Forks
110
Merge moyen
1 h 26 min
PR mergées (30 j)
3

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de microsoft/coreutils

Toutes les issues de microsoft/coreutils

Issues similaires

Plus d'issues Rust

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.