PowerShell integration breaks existing PSConsoleHostReadline
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 55/100
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
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de microsoft/coreutils
-
Add support for /dev/nullOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 55/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 30/100
-
Add tty (uutils supports it)Ouverte
Difficulté 3/5 Une demi-journée Accessibilité débutants 50/100
Toutes les issues de microsoft/coreutils
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
compiler P4 perf
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
HerringtonDarkholme/hd-lang#1044 ·
Les mainteneurs répondent en général sous 1 jour
-
good first issue help wanted r-docs
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
servo/rust-smallvec#824 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
akitaonrails/ai-usagebar#552 ·
Les mainteneurs répondent en général sous 1 jour