uva-cs / pdr

A repo for a Program and Data Representation university-level course
Other
91 stars 227 forks source link

Try harder on macOS #76

Closed 50Wliu closed 4 years ago

50Wliu commented 4 years ago

Since the /etc/path method apparently didn't work, this approach modifies the relevant profile files directly.

@disha-jain we discussed the potential consequences of directly appending to bash_profile. I did more research and found that some commonly-used software such as nvm does append to the profile, so if they do it without issues we should be able to as well.

The issue with this approach is that if they already have customized ~/.profile or ~/.bash_login, creating a ~/.bash_profile will completely ignore those modifications.

Since I don't keep wanting to bother Disha, I've recruited some Herefordians so that I can run commands on their laptops instead :).

50Wliu commented 4 years ago

Okay, I got to test this on someone running macOS 10.14. It doesn't appear that Macs have any of the profile files I mentioned by default, so we should be okay. I ran the same script on my ZSH Ubuntu instance and it worked, so hopefully that means it'll work on 10.15 as well, but I'll hold off for a bit to see if anyone else says they have 10.15.

50Wliu commented 4 years ago

Okay, I found someone with Catalina. When you upgrade to Catalina, the shell is preserved as Bash (this makes sense in case you have scripts that explicitly depend on Bash). So I think the "detect if ZSH_VERSION is set" method is the best way to go to determine which profile to write to.

50Wliu commented 4 years ago

More fun: I just looked into why bash_profile (login) is used instead of bashrc (interactive) on macOS. It's because every single shell is started as a login shell -.-