Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completing a relative path with a space and softlinks inside, turns it absolute (which breaks creating relative softlinks) #1223

Open
3 tasks done
navid-zamani opened this issue Jun 21, 2024 · 1 comment

Comments

@navid-zamani
Copy link

Describe the bug

Double-completing a relative path with a space in the name and softlinks inside it, results in it being turned into an absolute path.
This breaks attempts at passing relative paths to commands (like is common with ln).

To reproduce

  1. cd /tmp; mkdir TEST; cd TEST
  2. mkdir -p 'aaa/c c' 'aaa/xxx' 'aaa/yyy' bbb
  3. cd 'aaa/c c/'
  4. ln -s ../xxx; ln -s ../yyy
  5. cd ../../bbb
  6. ln -s ../aaa/c and press ⟨TAB⟩ once, to get ../aaa/c\ c/.
  7. Press ⟨TAB⟩ again. And get /tmp/TEST/aaa/c\ c/.

Expected behavior

One should get ../aaa/c\ c/ with
xxx/ yyy/
as suggestions.

Versions (please complete the following information)

  • Operating system name/distribution and version: Linux Mint 21.3 Virginia
  • bash version, echo "$BASH_VERSION": 5.1.16(1)-release
  • bash-completion version, (IFS=.; echo "${BASH_COMPLETION_VERSINFO[*]}"): 2.11

Additional context

It doesn’t happen, if there are no softlinks inside 'c c', of if there is no space in the name of that directory.
But a very similar problem happens for tilde (~). Which needs fixing for the same reason.
Also, I haven’t checked but suspect that if it transforms it like realpath does, turning any softlink component into the real path. (Which also breaks creating softlinks that use these other softlinks to work in several different environments.)

In my case I have several computers all syncing the same directories, but into a different base path since software expects those exact locations. Relative softlinks and softlinks that use other softlinks in their paths are the only way to get all paths to work on all systems. Especially since one of them is a Termux install on Android, where things like bind mounts don’t work, some paths (like pictures) are forcibly somewhere else, and $HOME is very different.

Debug trace

trace.log

@akinomyoga
Copy link
Collaborator

akinomyoga commented Jun 22, 2024

I cannot reproduce the problem. I also tried the combination of the reported versions, Bash-5.1.16 and bash-completion-2.11, but the problem doesn't arise. (edit: I now also tried it in Linux Mint 21.2 because I had a virtual machine, but the problem still doesn't reproduce). The provided trace.log doesn't seem to contain any /tmp/TEST/aaa/c c except the very last line (which is printed by Bash).

What are the result of the following commands (before and after the problem is triggered)?

$ complete -p ln
$ declare -p toks
$ shopt -p localvar_inherit

What are the results of the following commands?

$ echo "[$-]"
$ echo "$BASH_OPTS"
$ bind -v

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants