I share my .bashrc (all my dotfiles, actually) between ubuntu and archlinux. Since the paths may vary between them, I'd like to run some commands only on ubuntu (and others only on archlinux). How can i detect whether I am running ubuntu inside the .bashrc file? Detecting Debian will probably work.
|
feedback
|
|
The result of
This is the standard way in GNU makefiles. | |||
|
feedback
|
|
Think of it as different computers, not different operating systems:
| |||||
|
feedback
|
|
REVISED: the original version doesn't work on Ubuntu 10.04 which does not mention Ubuntu in uname -v. The /etc/lsb-release file is much better for this purpose as it has an explicit DISTRIB_ID line set to Ubuntu. Based on l0b0's response, this sh script detects Ubuntu with an if statement. As others have pointed out, depending on what you're doing it may be more appropriate to detect particular programs or features, but as someone who has written Ubuntu-specific installers I appreciate that sometimes a simple smoke test that someone is not misapplying them is all you want.
| ||||
|
feedback
|