Skip to content

Commit

Permalink
Fix handling of files without \n at end of file
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerzy Kozera committed Oct 8, 2018
1 parent 5c99790 commit e3a1667
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions detect_secrets/core/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,9 @@ def _get_secret_with_context(
if len(output) < end_line - start_line + 1:
# This handles the case of a short file.
num_lines_in_file = int(subprocess.check_output([
'wc',
'-l',
'grep', # https://stackoverflow.com/a/38870057
'-c', # - 'wc -l' cannot be used here because if the last char
'', # of the file isn't \n, then the last line isn't counted
filename,
]).decode('utf-8').split()[0])

Expand Down

0 comments on commit e3a1667

Please sign in to comment.