sharkdp/fd

[BUG] command execution (--exec) not working as expected

notDavid opened this issue · 3 comments

Checks

  • I have read the troubleshooting section and still think this is a bug.

Describe the bug you encountered:

Hi there,

Noob here, probably a misunderstanding on my side, but not sure what i'm doing wrong, can someone please advise?

Thank you!

bsh ❯ tree
.
├── test1
│   ├── 1.txt
│   └── 2.txt
└── test2
    ├── 3.txt
    └── 4.txt

3 directories, 4 files

 ~/tmp/test
bsh ❯ fd --exec rm -i
remove ./test2/4.txt? remove ./test1/2.txt? remove ./test1/1.txt? rm: ./test2: is a directory
rm: ./test1: is a directory
remove ./test2/3.txt?

 ~/tmp/test
bsh ❯ tree
.
├── test1
│   ├── 1.txt
│   └── 2.txt
└── test2
    ├── 3.txt
    └── 4.txt

3 directories, 4 files

 ~/tmp/test
bsh ❯ fd --exec rm -irv
remove ./test2/4.txt? remove ./test2/3.txt? remove ./test1/2.txt? examine files in directory ./test1? remove ./test1/1.txt? examine files in directory ./test2?

 ~/tmp/test
bsh ❯ tree
.
├── test1
│   ├── 1.txt
│   └── 2.txt
└── test2
    ├── 3.txt
    └── 4.txt

3 directories, 4 files

Describe what you expected to happen:

I would expect rm to ask for confirmation to delete each file & folder, but it just spams all the output and does nothing...

What version of fd are you using?

fd 9.0.0

Which operating system / distribution are you on?

macOS 14.2.1
arm64

I expect what is needed is something like xargs option -o ? :

-o
Reopen stdin as /dev/tty in the child process before executing the command.
This is useful if you want xargs to run an interactive application.

By default fd runs commands in parallel, so passing the input through to them would behave very weirdly. If you add -j1 it will work:

tavianator@graphene $ fd bar -j1 -x rm -i
rm: remove regular empty file './bar'? y

Thank you for explaining @tavianator 🙏🏼️ 👍🏼️