macvim-dev / macvim-dev/macvim

CLI tools don't preserve v:progname, v:progpath

Aperta
#1,192 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Vim Script
Stelle
7.9k
Fork
691
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Describe the bug
Vim exposes the name of the binary that was executed in the v:progname variable. Unfortunately, invoking the various vim CLI tools installed by MacVim always reports v:progname as being Vim. This is because they're all symlinks of the embedded mvim script, which ultimately invokes

exec "$binary" $opts …

In particular, it's not providing the -a flag, so the binary is always invoked with the executable name of Vim.

The same issue also affects v:progpath (for obvious reasons), wherein it always points to the absolute path to the MacVim.app/Contents/MacOS/Vim binary.

This is an issue because v:progname and v:progpath are potentially useful to use in my vimrc to customize based on what binary I used to invoke it.

Replacing this with exec -a "$0" "$binary" … should solve the problem.

On a related note, launching MacVim from the Finder also sets v:progname to Vim. I can't decide if this matters.

To Reproduce
Detailed steps to reproduce the behavior:

  1. Run ex
  2. Type echo v:progname or echo v:progpath

Expected behavior
It should print "ex" as the progname and either "ex" or the absolute path to ex as the progpath.

Observed behavior
It always prints Vim as the progname and the absolute path to MacVim.app/Contents/MacOS/Vim as the progpath.

Environment (please complete the following information):

  • Vim version 8.2.1719
  • OS: macOS 11.2.3 (20D91)
  • Terminal: Apple Terminal.app or GUI

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con lo script mvim incorporato e analizza come invoca il binario Vim per gli strumenti CLI collegati simbolicamente. Riproduci il caso con ex e echo v:progname e v:progpath, quindi verifica che l'invocazione conservi il nome o il percorso dello strumento senza modificare gli altri comportamenti di avvio.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
macos, shell, vim
Ambito
cli, operating-systems
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.