-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add option to exclude shebang from the count #827
Comments
The reason cloc counts the #!/usr/bin/perl -n -i print if /4/; One line or two? If you only count the print statement you miss the bulk of the logic which in this case is "loop over every line in the input file and perform an in-place edit but do not print the result." Adding I'll grant you that few scripts with Adding a 7071 # chomp( $original_lines[0] ); 7072 # if (defined $Script_Language{$language} and 7073 # $original_lines[0] =~ /^#!/ and 7074 # (!scalar(@lines) or ($lines[0] ne $original_lines[0]))) { 7075 # unshift @lines, $original_lines[0]; # add the first line back 7076 # } The script language is already identified by this point so no harm done. |
Thanks, I learned something today! 😄 I only ever used standard shebangs with things like In my particular use case, I use Perhaps we can count the shebang line only for languages where command-line parameters matter (like |
But it isn't just In any case, regarding code golf, wouldn't the results be the same if all scripts count |
Again, learned something new, thanks! 😄 For the code golf, we also accept files in non-scripting languages, e.g. C++ and Java, which do not require the shebang. |
Closing as: won't implement. |
Hi! Thanks for maintaining
cloc
for all these years 😄I have been manually changing
cloc
to exclude the shebang from the count for quite some time now, by commenting out this line:cloc/cloc
Line 7078 in 657038f
Can you explain why
cloc
considers a shebang as a line of code? And if you think that the shebang should be part of the count by default, can we add an option to exclude it? I can probably write the PR myself, I'm just not sure what the option should be called, because something like--exclude-shebang
may also imply that the shebang is not used to detect the language, which is not what I want 🙂The text was updated successfully, but these errors were encountered: