Closed wavexx closed 6 months ago
Yes, I agree that this is a valid use case to only recursively search the specified targets without descending into other FS. Like find -x
, this is something we can do.
The only question is whether we need yet another long option for this. Because we have two related options --include-fs=
and --exclude-fs=
we may want to use one of them for this feature, for example when no mount argument is specified. So perhaps --exclude-fs
without an argument is suitable for this feature? Since find -x
or find -xdev
pronounce as "ex", it might be a reasonable choice?
Seems reasonable, and I agree that avoiding another flag is a good thing™
I've implemented the new feature in my dev version to try it out.
So you can use --exclude-fs
or --exclude-fs=
without MOUNT points.
For the help info and man page, I'm considering the following update:
--exclude-fs=MOUNTS
Exclude file systems specified by MOUNTS from recursive searches.
MOUNTS is a comma-separated list of mount points or pathnames to
directories. When omitted, prevents descending into file systems
that are not associated with the specified file and directory
search targets. Note that --exclude-fs=MOUNTS take priority over
--include-fs=MOUNTS. This option may be repeated.
As a minor point, I want to clarify that if no search targets are explicitly specified, then implicitly the search target is the working directory. In that case, only the FS associated with the working directory is searched.
Alternative wording:
--exclude-fs=MOUNTS
Exclude file systems specified by MOUNTS from recursive searches.
MOUNTS is a comma-separated list of mount points or pathnames to
directories. When omitted, only descends into the file systems
associated with the specified file and directory search targets.
Note that --exclude-fs=MOUNTS take priority over
--include-fs=MOUNTS. This option may be repeated.
I like this a bit better. Less confusing. No double negation in a sentence.
To avoid breaking symmetry of these two options, a default --include-fs
could be useful as a shorthand for --include-fs=.
:
--include-fs=MOUNTS
Only file systems specified by MOUNTS are included in recursive
searches. MOUNTS is a comma-separated list of mount points or
pathnames to directories. When omitted, restricts recursive
searches to the file system of the working directory only, same as
--include-fs=. (dot). Note that --exclude-fs=MOUNTS take priority
over --include-fs=MOUNTS. This option may be repeated.
As a minor point, I want to clarify that if no search targets are explicitly specified, then implicitly the search target is the working directory. In that case, only the FS associated with the working directory is searched.
Very good point!
As a minor point, I want to clarify that if no search targets are explicitly specified, then implicitly the search target is the working directory. In that case, only the FS associated with the working directory is searched.
Very good point!
In that case it's the same as --include-fs=.
because we're searching the working directory without descending into other devices. So there are two ways to get the same. But writing that in the man page would make it more confusing than it really is.
Implemented.
I'd like to always restrict the search to the filesystems of all paths which are given on the command line during interactive usage, as
find -xdev
does. As a common example:ug pattern /var
should search inside the filesystem of /var, but exclude any other fs (such as a nested tmpfs). The --include-fs requires doubling all the arguments, which doesn't really work well with shell aliases or functions. For example, if I give two starting paths on two filesystems, it's generally implied I want both filesystems to be included:
ug pattern /fs1 /fs2
which would require
--include-fs=/fs1,/fs2
or two extra args. The suggested--include-fs=.
is not really a good substitute for this behavior, since very often $CWD has nothing to do with the searched paths.