Commit fa82c02a authored by Guido van Rossum's avatar Guido van Rossum

Changed logic so it now replaces anything that has #! and python in

the first line, replacing the entire line.
parent 0fb5423c
#! /usr/local/bin/python #! /usr/bin/env python
# Change the #! line occurring in Python scripts. The new interpreter # Change the #! line occurring in Python scripts. The new interpreter
# pathname must be given with a -i option. # pathname must be given with a -i option.
...@@ -139,12 +139,11 @@ def fix(filename): ...@@ -139,12 +139,11 @@ def fix(filename):
# Return succes # Return succes
return 0 return 0
prog = regex.compile('\(#![ \t]*\)\(/[^ \t\n]*\)\(.*\n\)')
def fixline(line): def fixline(line):
if prog.match(line) < 0: if line[:2] != '#!':
return line
if string.find(line, "python") < 0:
return line return line
head, tail = prog.group(1, 3) return '#! %s\n' % new_interpreter
return head + new_interpreter + tail
main() main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment