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

Preserve non utf8 filenames #558

Merged
merged 7 commits into from
Apr 4, 2020
Merged

Preserve non utf8 filenames #558

merged 7 commits into from
Apr 4, 2020

Conversation

sharkdp
Copy link
Owner

@sharkdp sharkdp commented Apr 4, 2020

This PR fixes the handling of filesystem entries with invalid UTF-8 names (#295). It is an adapted version of #309 by @alexmaco (thank you for your initial work!).

Invalid UTF-8 filenames are properly passed to child-processes when using --exec, --exec-batch or --list-details:

image

There are a few things to note:

  • fd -x echo will print the actual invalid UTF-8 sequence, as expected
  • if you call fd -x echo, you might still see "test_�invalid.txt" if your terminal emulator wants to save you from scrambled output.
  • fd -l properly passes the filename to ls
  • fd … -x rm properly passes the filename to rm

If not using -x or -X, we still make sure to print the "invalid UTF-8 sequence" character "�". However, if we pipe the output to another program (like xargs), we pass the filenames as is (on Unix):

> fd
test_�invalid.txt

> fd | xargs ls
'test_'$'\376''invalid.txt'

fixes #295

@sharkdp sharkdp merged commit 95eae00 into master Apr 4, 2020
@sharkdp sharkdp deleted the preserve-non-utf8-filenames branch April 4, 2020 16:46
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

Successfully merging this pull request may close these issues.

fd outputs � for filenames containing extended ascii
1 participant