← every case · 2000 · string forms

2120-heredoc_holding_an_apostrophe

an apostrophe inside the body of a shell heredoc. The word that ends a heredoc is chosen where it is written, so no fixed list of comment and string symbols can say what closes this one. The body holds a line beginning with #, so a counter that does not read heredocs counts that line as a comment, unless the apostrophe has opened a string that runs on, and then it counts the comments at the end as code

read ascloc.defaultcloc.docstring-as-codecodestats.defaultmezura.contentmezura.regionscc.defaulttokei.default
input.sh
1codecat <<TEXT
2codeit's fine in here
3code# and this line is inside the heredoc too
4codeTEXT
5comments# a real comment
6comments# a second real comment

stringcommentthe tag around another language

What each tool answered

cloc.default ✗ fails

it reads no heredocs, so the line beginning with # inside one counts as a comment

the rules ask6 lines · 0 blanks · 4 code · 2 comments
it answers6 lines · 0 blanks · 3 code · 3 comments

cloc --json --config /tmp/linejudge-empty-file cases/2000-string_forms/2120-heredoc_holding_an_apostrophe/input.sh

cloc.default ✗ fails

--strip-str-comments

it reads no heredocs, so the line beginning with # inside one counts as a comment

the rules ask6 lines · 0 blanks · 4 code · 2 comments
it answers6 lines · 0 blanks · 3 code · 3 comments

cloc --json --config /tmp/linejudge-empty-file cases/2000-string_forms/2120-heredoc_holding_an_apostrophe/input.sh --strip-str-comments

cloc.docstring-as-code ✗ fails

it reads no heredocs, so the line beginning with # inside one counts as a comment

the rules ask6 lines · 0 blanks · 4 code · 2 comments
it answers6 lines · 0 blanks · 3 code · 3 comments

cloc --json --config /tmp/linejudge-empty-file cases/2000-string_forms/2120-heredoc_holding_an_apostrophe/input.sh --docstring-as-code

codestats.default ✓ agrees
the rules ask6 lines · 0 blanks · 4 code · 2 comments
it answers6 lines · 0 blanks · 4 code · 2 comments

codestats cases/2000-string_forms/2120-heredoc_holding_an_apostrophe/input.sh --output json-compact --include-generated --no-gitignore --hidden --no-config

mezura.content ✓ agrees
the rules ask6 lines · 4 code · 2 comments · 0 extra
it answers6 lines · 4 code · 2 comments · 0 extra

mezura cases/2000-string_forms/2120-heredoc_holding_an_apostrophe/input.sh --output json --hide timing --no-default-config --no-local --counting content

mezura.region ✓ agrees
the rules ask6 lines · 0 blanks · 4 code · 2 comments
it answers6 lines · 0 blanks · 4 code · 2 comments

mezura cases/2000-string_forms/2120-heredoc_holding_an_apostrophe/input.sh --output json --hide timing --no-default-config --no-local --counting region

scc.default ✗ fails

it reads no heredocs, so the apostrophe opens a string and every line under it is counted as code. Without the apostrophe the line beginning with # inside the heredoc counts as a comment

the rules ask6 lines · 0 blanks · 4 code · 2 comments
it answers6 lines · 0 blanks · 6 code · 0 comments

scc --format json --no-config cases/2000-string_forms/2120-heredoc_holding_an_apostrophe/input.sh

tokei.default ✗ fails

it reads no heredocs, so the apostrophe opens a string and every line under it is counted as code. Without the apostrophe the line beginning with # inside the heredoc counts as a comment

the rules ask6 lines · 0 blanks · 4 code · 2 comments
it answers6 lines · 0 blanks · 6 code · 0 comments

tokei --output json cases/2000-string_forms/2120-heredoc_holding_an_apostrophe/input.sh