From 1fb1baab1f4e3ddfcbf17c304456ecd40cf75f8e Mon Sep 17 00:00:00 2001 From: 5nafu Date: Sat, 11 Jul 2015 18:44:48 +0200 Subject: [PATCH 1/2] Use lsb_release instead of /etc/issue and add debian as OS --- bin/dotfiles | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/dotfiles b/bin/dotfiles index 7c269c75bf..e72df58bc2 100755 --- a/bin/dotfiles +++ b/bin/dotfiles @@ -43,10 +43,13 @@ function is_osx() { [[ "$OSTYPE" =~ ^darwin ]] || return 1 } function is_ubuntu() { - [[ "$(cat /etc/issue 2> /dev/null)" =~ Ubuntu ]] || return 1 + [[ "$(lsb_release -s -i)" =~ Ubuntu ]] || return 1 +} +function is_debian() { + [[ "$(lsb_release -s -i)" =~ Debian ]] || return 1 } function get_os() { - for os in osx ubuntu; do + for os in osx ubuntu debian; do is_$os; [[ $? == ${1:-0} ]] && echo $os done } From 42511cf21dd9bba46e4723f718e37ad1725cf342 Mon Sep 17 00:00:00 2001 From: 5nafu Date: Sat, 11 Jul 2015 21:49:12 +0200 Subject: [PATCH 2/2] there is no lsb_release on osx, therefor we need to check for this first. Prevents messegaes on stdout/stderr on osx --- bin/dotfiles | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/dotfiles b/bin/dotfiles index e72df58bc2..c63427ae96 100755 --- a/bin/dotfiles +++ b/bin/dotfiles @@ -43,10 +43,10 @@ function is_osx() { [[ "$OSTYPE" =~ ^darwin ]] || return 1 } function is_ubuntu() { - [[ "$(lsb_release -s -i)" =~ Ubuntu ]] || return 1 + type lsb_release &>/dev/null && [[ "$(lsb_release -s -i)" =~ Ubuntu ]] || return 1 } function is_debian() { - [[ "$(lsb_release -s -i)" =~ Debian ]] || return 1 + type lsb_release &>/dev/null && [[ "$(lsb_release -s -i)" =~ Debian ]] || return 1 } function get_os() { for os in osx ubuntu debian; do