From: Simon Ruderich Date: Sun, 1 Mar 2009 15:17:42 +0000 (+0100) Subject: lib.sh: Add os function which returns current OS. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=144b79caff995d7c5773e3efb66813bf131de0e2;p=config%2Fdotfiles.git lib.sh: Add os function which returns current OS. Works on Debian and Mac OS X at the moment. --- diff --git a/lib.sh b/lib.sh index 5576bce..ea61359 100644 --- a/lib.sh +++ b/lib.sh @@ -17,6 +17,19 @@ installed() { which $1 | grep -E '^/' > /dev/null } +# Prints the current OS. Supported are Debian (debian) and Mac OS X (darwin) +# at the moment. If an unsupported OS is used an error is printed. +os() { + if [ -f /etc/debian_version ]; then + echo debian + elif [ x`uname` = xDarwin ]; then + echo darwin + else + echo unsupported OS! >&2 + return 1 + fi +} + # Creates a symbolic link for file $1 in dirname of $2 with name of basenmae # $2. #