Open navid-zamani opened 1 week ago
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
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
cd /tmp; mkdir TEST; cd TEST
mkdir -p 'aaa/c c' 'aaa/xxx' 'aaa/yyy' bbb
cd 'aaa/c c/'
ln -s ../xxx; ln -s ../yyy
cd ../../bbb
ln -s ../aaa/c
and press ⟨TAB⟩ once, to get../aaa/c\ c/
./tmp/TEST/aaa/c\ c/
.Expected behavior
One should get
../aaa/c\ c/
withxxx/ yyy/
as suggestions.Versions (please complete the following information)
echo "$BASH_VERSION"
: 5.1.16(1)-release(IFS=.; echo "${BASH_COMPLETION_VERSINFO[*]}")
: 2.11Additional 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