Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d5c58c3

Browse files
committed
Changed logic so it now replaces anything that has #! and python in
the first line, replacing the entire line.
1 parent fc05882 commit d5c58c3

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

Tools/scripts/pathfix.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /usr/local/bin/python
1+
#! /usr/bin/env python
22

33
# Change the #! line occurring in Python scripts. The new interpreter
44
# pathname must be given with a -i option.
@@ -139,12 +139,11 @@ def fix(filename):
139139
# Return succes
140140
return 0
141141

142-
prog = regex.compile('\(#![ \t]*\)\(/[^ \t\n]*\)\(.*\n\)')
143-
144142
def fixline(line):
145-
if prog.match(line) < 0:
143+
if line[:2] != '#!':
144+
return line
145+
if string.find(line, "python") < 0:
146146
return line
147-
head, tail = prog.group(1, 3)
148-
return head + new_interpreter + tail
147+
return '#! %s\n' % new_interpreter
149148

150149
main()

0 commit comments

Comments
 (0)