Macports sudo expands ~ to /var/root in python
- by calavera
This might be a bit dev-heavy for the site... but here goes.
I installed the macports version of sudo. All is well, except for one thing. Using python 2.6 to expand ~ to the user's home directory results in a different output than the version of sudo that comes with Snow Leopard.
For example consider the following python code:
#expand_home_dir.py
import os
os.path.expanduser('~')
Below are 3 different calls of the code listed above. The first call using sudo is using the Macports version because my $PATH begins with /opt/local/bin:
robert$ python2.6 expand_home_dir.py
/Users/robert
robert$ sudo python2.6 expand_home_dir.py
/var/root
robert$ /usr/bin/sudo python2.6 expand_home_dir.py
/Users/robert
Any idea why this is happening?