AlDanial / cloc

cloc counts blank lines, comment lines, and physical lines of source code in many programming languages.
GNU General Public License v2.0
19.78k stars 1.02k forks source link

Support trailing slash with --match-d #732

Closed PMExtra closed 1 year ago

PMExtra commented 1 year ago

For example, we have the structure:

|- src
|  |- foo
|  |  |- bar.cpp
|  |- baz.cpp
|- srcx
|  |- x.cpp

If I specified --match-d=/src/ options, it will only match the src/foo folder and only found the src/foo/bar.cpp file. The src/baz.cpp will be not matched.

It's not my expected result. I think --match-d=/src/ should also match itself rather than subdirectory only.

For now, I have to set --match-d=/src(/|$) to achieve.

AlDanial commented 1 year ago

Re: return unless "$Dir/" =~ m{$opt_match_d} or $Dir =~ m{$opt_match_d} . Good idea.