Skip to content

fix: trailing space incorrectly added to some directories #53

Description

@dberlin

There is code that purports to avoid adding trailing spaces to directory expansions, here:

if test (count $result) -eq 1; and not test -d (string unescape -- $result[1])

This works for some directories, but if you do something like cd ~/foo<tab> where foo is the unique prefix of a directory in your homedir, it will add a space.

Presumably because it is not tilde-expanding the result when it's a string. test -d does not tilde expand strings. In fact, i can't find any function that does - path resolve will not do it, etc.

It looks like fish added a way to expand tokens in master, which will be nice someday when everyone is on fish 3.8.
See the end of fish-shell/fish-shell#5793

Otherwise, the only way to make this work seems to be
eval "echo" <string>

IE
replacing
set -a result (string join -- "" "~" (string sub --start 2 -- $token | string escape))
with
set -a result (eval 'echo' (string join -- "" "~" (string sub --start 2 -- $token | string escape)))

makes it all work
this seems super ugly but even the bug report above mentions it as the way to get everything expanded.
Happy to prepare a patch.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions