fd: [BUG] `--strip-cwd-prefix` does nothing

Sorry for not using the official bug template, it always returned error code 400 on my end, and acted pretty buggy in general.

Bug description

I use a variant of the following line to find pdf files and sort them by date:

fd --strip-cwd-prefix -e pdf -X ls -t

--strip-cwd-prefix should remove the leading ./ string from the output (as per https://github.com/sharkdp/fd/pull/861). However, this string is still present in the output of fd in my interactive shell session, as well as in my shell scripts.

Expected behavior

fd should always remove the leading ./ when I invoke it with --strip-cwd-prefix.

Version information

$ fd --version
fd 8.3.0
$ uname -srm
Linux 5.15.5-arch1-1 x86_64
$ lsb-release -a
-e LSB Version:	1.4
-e Distributor ID:	Arch
-e Description:	Arch Linux
-e Release:	rolling
-e Codename:	n/a

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (6 by maintainers)

Commits related to this issue

Most upvoted comments

The -t option to ls should sort by time, newest first. Maybe xargs is splitting it into multiple calls to ls?

The following script still outputs the ./ prefix confused

#/bin/sh
fd -0 -e pdf | xargs -0 ls -t | dmenu

Ah, sorry. My bad. Still needs the --strip-cwd-prefix option, of course. Also, to avoid https://github.com/sharkdp/fd/issues/760, we should add a -- argument to ls:

fd --strip-cwd-prefix -0 -e pdf | xargs -0 ls -t -- | dmenu