macvim-dev / macvim-dev/macvim

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

Open
#1,192 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Vim Script
Stars
7.9k
Forks
691
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the embedded mvim script and inspect how it invokes the Vim binary for symlinked CLI tools. Reproduce with ex and echo v:progname and v:progpath, then verify that the invocation preserves the tool name or path without changing other launch behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, shell, vim
Domain
cli, operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.