do not create shebang.bak file
This commit is contained in:
parent
c803f7ae98
commit
1724ff5658
@ -34,6 +34,7 @@
|
|||||||
# here, as it is the shortest I could find on a modern OS.
|
# here, as it is the shortest I could find on a modern OS.
|
||||||
shebang_limit = 127
|
shebang_limit = 127
|
||||||
|
|
||||||
|
|
||||||
def shebang_too_long(path):
|
def shebang_too_long(path):
|
||||||
"""Detects whether a file has a shebang line that is too long."""
|
"""Detects whether a file has a shebang line that is too long."""
|
||||||
with open(path, 'r') as script:
|
with open(path, 'r') as script:
|
||||||
@ -57,16 +58,10 @@ def filter_shebang(path):
|
|||||||
if original.startswith(new_sbang_line):
|
if original.startswith(new_sbang_line):
|
||||||
return
|
return
|
||||||
|
|
||||||
backup = path + ".shebang.bak"
|
|
||||||
os.rename(path, backup)
|
|
||||||
|
|
||||||
with open(path, 'w') as new_file:
|
with open(path, 'w') as new_file:
|
||||||
new_file.write(new_sbang_line)
|
new_file.write(new_sbang_line)
|
||||||
new_file.write(original)
|
new_file.write(original)
|
||||||
|
|
||||||
copy_mode(backup, path)
|
|
||||||
unset_executable_mode(backup)
|
|
||||||
|
|
||||||
tty.warn("Patched overly long shebang in %s" % path)
|
tty.warn("Patched overly long shebang in %s" % path)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user