Right now I'm forced to resort to using uname to get the operating system name and it works. But in bash there is the OSTYPE environment variable that is automatically set and I was wondering if there is something similar.
Asked
Active
Viewed 2,741 times
18
Édouard Lopez
- 40,270
- 28
- 126
- 178
RubenLaguna
- 21,435
- 13
- 113
- 151
1 Answers
20
From the fish user documentation it seems that the canonical way to execute code conditionally depending on the operating system type is using a switch statement with the uname results. See example:
switch (uname)
case Linux
echo Hi Tux!
case Darwin
echo Hi Hexley!
case FreeBSD NetBSD DragonFly
echo Hi Beastie!
case '*'
echo Hi, stranger!
end
RubenLaguna
- 21,435
- 13
- 113
- 151