command-line-api icon indicating copy to clipboard operation
command-line-api copied to clipboard

Completions don't work for symlinked executables

Open mtaron opened this issue 2 years ago • 1 comments

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

# 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.

mtaron avatar May 25 '23 22:05 mtaron

Ah, very helpful. Thanks!

Would you like to submit a PR with that change?

jonsequitur avatar May 25 '23 22:05 jonsequitur