Safest method to convert "linuxisms" to FreeBSD (symlink or shebang editing)?

Just a quick question in regards to converting files (python scripts) written for Linux to use FreeBSD.
For example should I just edit every file from
Code:
#!/usr/bin/python
to
Code:
#!/usr/local/bin/python2.7
or should I just symlink the binary to what it's being called for
Code:
ln -s /usr/local/bin/pyhton2.7 /usr/bin/python
?
Thanks
 
This should work for both FreeBSD and Linux, assuming python is in the PATH (it normally is):
Code:
#!/usr/bin/env python
 
The Python folks recommend the following because it is most portable and doesn't depend on the OS. Just make sure python is in your $PATH.
Code:
#!/usr/bin/env python
If your script depends on a certain version of Python, you should write python2 or even python2.7. Note that Python 2.x is considered legacy, Python 3 is the default for quite some time. So if you use “python” only, you get Python 3 (currently 3.6, to be exact).
 
or should I just symlink the binary to what it's being called for
Code:
ln -s /usr/local/bin/pyhton2.7 /usr/bin/python
?
As a rule of thumb: never mess with the base system like this. For the simple reason that these changes could easily be undone after an upgrade which could then break quite a few things. If you need a symlink then dump it in /usr/local/bin. And if that doesn't work then simply change your searchpath.

(edit): of course the better solution has been mentioned above, my answer only covers editing the base system.
 
Back
Top