[BUG] Wrong result when --full-path and ..
Rom888 opened this issue · 3 comments
Checks
- I have read the troubleshooting section and still think this is a bug.
Describe the bug you encountered:
mkdir /tmp/1
cd /tmp/1
touch foo
mkdir /tmp/1/2
cd /tmp/1/2
fd --full-path -t f '/tmp/1/foo' ..
# no result here, but expected: ../foo
fd --full-path -t f '/tmp/1/.*/.*/foo' ..
# it seems to me that this result should not be here, but the result is: ../foo
Describe what you expected to happen:
No response
What version of fd
are you using?
fd 9.0.0
Which operating system / distribution are you on?
$ uname -srm
Linux 6.5.9-t2-lunar x86_64
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 23.04
Release: 23.04
Codename: lunar
Hmm i suspect the path it is comparing to might be
/tmp/1/2/../foo
@tmccombs That's my guess too. But trying to confirm with --absolute-path
causes it to not match any more! I guess that's another bug.
So if --absolute-path
is specified, we eagerly normalize the command line search paths:
Lines 666 to 672 in 4efc05e
Without --absolute-path
, the search path stays as-is (..
). Then later when matching, if --full-path
is given, we call path_absolute_form()
:
Lines 513 to 516 in b874462
But path_absolute_form()
doesn't normalize:
Lines 14 to 21 in b874462
I think having --absolute-path
change the result set is a bug we need to fix. But we need to be careful.