dotnet / dotnet/command-line-api

Completions don't work for symlinked executables

Offen
#2,201 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Area-Completions bug
Vorherrschende Sprache
C#
Sterne
3.7k
Forks
428
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

It's pretty common to "install" executables on Linux by symlinking them into `$XDG_BIN_DIR`, e.g. `ln --symbolic "$XDG_DATA_HOME/go/bin/go" "$XDG_BIN_DIR/go"`

I tried something similar with a dotnet CLI I created using System.CommandLine, but I couldn't get completions to work. I tracked it down to [this line](https://github.com/dotnet/command-line-api/blob/7058640c8f0c472c399bc063e14410a04cbe5ffd/src/System.CommandLine.Suggest/dotnet-suggest-shim.zsh#LL12C11-L12C11)

```
# Get full path to script because dotnet-suggest needs it
# NOTE: this requires a command registered with dotnet-suggest be
# on the PATH
full_path=`which ${words[1]}` # zsh arrays are 1-indexed
```

Switching this to `full_path=$(realpath $(which ${words[1]}))` fixed the issue.

Would be nice for the official shims (or dotnet-suggest itself if the fix is more appropriate there) to support symlinked executables.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne in src/System.CommandLine.Suggest/dotnet-suggest-shim.zsh bei der verlinkten Zuweisung von full_path und vergleiche, wie eine direkt aufgerufene ausführbare Datei mit einer symbolisch verknüpften Datei aufgelöst wird. Reproduziere die Vervollständigung für einen über einen symbolischen Link installierten Befehl und überprüfe anschließend, ob der offizielle Shim oder dotnet-suggest den aufgelösten Pfad der ausführbaren Datei korrekt verarbeitet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp, zsh
Bereich
cli
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.