Skip to content

Commit

Permalink
Do not crash on empty files.
Browse files Browse the repository at this point in the history
Without this, one gets the following backtrace:
    313     def strip_shebang(file_lines):
--> 315         if file_lines[0].startswith("#!/"):
    316             del file_lines[0]
    317             file_lines =
ConfigFile.trim_file_whitespace(file_lines)
IndexError: list index out of range
  • Loading branch information
unbrice authored and evanpurkhiser committed Dec 26, 2015
1 parent f0d4aaa commit 1b0ef96
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bin/dots
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class ConfigFile(object):
@staticmethod
def strip_shebang(file_lines):
"""Removes the shebang from the first line of a list"""
if file_lines[0].startswith("#!/"):
if file_lines and file_lines[0].startswith("#!/"):
del file_lines[0]
file_lines = ConfigFile.trim_file_whitespace(file_lines)

Expand Down

0 comments on commit 1b0ef96

Please sign in to comment.