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.72k stars 1.02k forks source link

--csv-delimiter doesn't work #832

Closed batichotti closed 5 months ago

batichotti commented 5 months ago

Bug founded on Windows and Linux

CLoC doesn't change the delimiter when --csv-delimiter=; is on. If we change the syntax to something that doesn't work the CLoC falls and raises an error, but with the syntax below nothing happens.

(context: the code is a Python script)

system(f"{cloc} --by-file-by-lang --csv --csv-delimiter={DELIMITER} --out={output_path}/{language}/{repository}.csv {input_path}/{language}/{repository}")

The result is the same without the command, just the CLoC separated by commas, but we want ; as the delimiter.

Am I wrong or is the code broken?

AlDanial commented 5 months ago

If you replace system() with print(), what is the output? I'd like to see the full command that was issued.

AlDanial commented 5 months ago

The reason, at least on Linux, is most likely that the semicolon needs to be quoted, otherwise the shell will think you're supplying two commands. Give this a try:

system(f"{cloc} --by-file-by-lang --csv --csv-delimiter='{DELIMITER}' --out={output_path}/{language}/{repository}.csv {input_path}/{language}/{repository}")

where single quotes surround the delimiter.

batichotti commented 5 months ago

We fixed this problem trading the ";" to "|". Thank you for help.

batichotti commented 5 months ago

And you are right, the quotes made the difference.