Resolve relative paths in complete by Caroleq · Pull Request #7992 · fish-shell/fish-shell
Description
PR resolves issue that completions for paths don't work for relative paths.
Reason for a bug is that path_get_path does not return full path as it is told in the function description, but returns unmodified cmd or path + cmd where path is taken from PATH e.g. for ../../dir1/exec1 path_get_path will return ../../dir1/exec1.
From what I checked this function is used by (I skip functions which don't store path i.e. out_path is null and parse_cmd_string):
populate_plain_processpasses value frompath_get_pathto exec function. Relative path should not be changed to absolute here because e.g. whole command path for a process is later seen in process info (this can be checked e.g. withps -efon Linux)builtin_commanduses value frompath_get_pathto print command that would be executed - I would also rather leave it as it is now
My proposal to solve it is to pass additional flag to path_get_path indicating if path should be returned as absolute. parse_cmd_string will always return absolute path which can be later matched with path completion if a one was defined. I didn't add function converting path to absolute in section checking if cmd is located in $PATH, because paths in $PATH should be absolute already and cmd doesn't have any slashes (otherwise it would be handled at the beginning of the function).
Fixes issue #6001
TODOs:
- Changes to fish usage are reflected in user documentation/manpages.
- Tests have been added for regressions fixed
- User-visible changes noted in CHANGELOG.rst