PowerShell integration breaks existing PSConsoleHostReadline
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 55/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- Rust
- Sterne
- 5.3k
- Forks
- 110
- Ø Merge
- 1 Std. 26 Min.
- Gemergte PRs (30 T.)
- 3
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoft/coreutils
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 55/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 30/100
-
Schwierigkeit 3/5 Ein halber Tag Anfängerfreundlichkeit 50/100
Alle Issues in microsoft/coreutils
Ähnliche Issues
-
Add a just recipe that runs the workflow linters locallyEvtl. vergeben @sgamelin hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
-
good first issue security
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
-
Status bar: a progress line that keeps the same text (import at 0%) ages out after 8 s and blinksOffenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
transit-audio/transit#216 ·
-
area: effects devices enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
suhina-daw/suhina-daw#1060 ·
Maintainer antworten meist innerhalb von 1 Tag