Optionally allow pattern elision · Issue #312 · sharkdp/fd (original) (raw)

I think having the directory separator in the pattern/path disambiguates sufficiently (and is consistent with some things in Linux - think of ‘ls -l’ of a directory symlink with/without a trailing slash.

Ok, but ls -l always expects a PATH argument. For fd, we would change the semantics of the argument from PATH to PATTERN. I can definitely see how that could be very confusing.

I was thinking of a flag to indicate that if the error situation was seen, to tell fd which option (if either) to use. Then an ‘fd’ alias could be defined with that option set. Say ‘--pattern-or-path=(path|pattern|none)’?

I'd like to avoid "bloat" when it comes to command line options (longer --help output, additional tests due to more possible command line combinations, etc), so I always hesitate when new command line options are suggested. This one in particular does not feel very natural to me. One option could be a more general --path-before-pattern command-line flag (maybe someone has an idea for a better name), which would change fd's usage from

fd [FLAGS/OPTIONS] [<pattern>] [<path>...]

to

fd [FLAGS/OPTIONS] [<path>] [<pattern>]

or possibly even

fd [FLAGS/OPTIONS] [<path>] [<pattern>...]

which would have other benefits as well.