mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	Changed logic so it now replaces anything that has #! and python in
the first line, replacing the entire line.
This commit is contained in:
		
							parent
							
								
									fc0588241c
								
							
						
					
					
						commit
						d5c58c34db
					
				
					 1 changed files with 5 additions and 6 deletions
				
			
		| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
#! /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):
 | 
				
			||||||
	# 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
 | 
							return line
 | 
				
			||||||
	head, tail = prog.group(1, 3)
 | 
						if string.find(line, "python") < 0:
 | 
				
			||||||
	return head + new_interpreter + tail
 | 
							return line
 | 
				
			||||||
 | 
						return '#! %s\n' % new_interpreter
 | 
				
			||||||
 | 
					
 | 
				
			||||||
main()
 | 
					main()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue