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

Exclude macOS containers from default find commands #3647

Closed

Conversation

timhillgit
Copy link

Specifically, exclude any file with the com.apple.containermanager.uuid extended attribute from the default Ctrl-T and Alt-C commands.

See additional discussion at #2705

Specifically, exclude any file with the com.apple.containermanager.uuid
extended attribute from the default Ctrl-T and Alt-C commands.
Comment on lines 20 to 24
local cmd opts macos_exclude
if [[ "$(uname -s)" == "Darwin" ]]; then
macos_exclude="-o -xattrname 'com.apple.containermanager.uuid'"
fi
cmd="${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' $macos_exclude \\) -prune \
Copy link
Owner

@junegunn junegunn Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about if we keep it simple and just put -xattrname 'com.apple.containermanager.uuid' regardless of the platform? Will there be any negative consequences for non-macOS users?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately yes. When find encounters a predicate it doesn't recognize it bails immediately and produces no results. Which actually brings up another issue: if someone on macOS has installed GNU find and deliberately placed it earlier on their PATH this command will similarly fail. On the one hand doing this is a "buyer beware" sort of situation but it's not that uncommon.

I can think of a few ways of dealing with this:

  1. Ignore it. Buyer beware.
  2. Instead of uname check if find /dev/null -xattrname 'com.apple.containermanager.uuid' 2> /dev/null succeeds.
  3. Instead of command find use /usr/bin/find.

2 is probably the least disruptive but is still adding complexity.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, -xattrname is not available on GNU find. It's unfortunate.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and did number 2. I haven't been able to test this on fish yet but otherwise I think this should work.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Honestly, I don't know how I feel about this. Are these conditional branches which add complexity and degrade the readability worth it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm no longer sure. The fact that my most recent commit had a bug is a vote against it. I'll keep it open for a bit longer though.

@timhillgit
Copy link
Author

Closed in favor of #3649

@timhillgit timhillgit closed this Mar 13, 2024
@timhillgit timhillgit deleted the exclude-macos-containers branch March 13, 2024 13:20
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.

2 participants