From 9756fee21152847f27a2514d2bac32cee03db9ac Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Thu, 9 Nov 2017 11:40:37 -0500 Subject: [PATCH] refactoring some good core funcs from rev control --- scripts/core/functions.sh | 21 +++++++++++++++++++++ scripts/rev_control/version_control.sh | 15 --------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index 45980cee..4991adf8 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -772,6 +772,27 @@ return 0 ############## + # echoes the machine's hostname. can be used like so: + # local my_host=$(get_hostname) + function get_hostname() + { + # there used to be more variation in how to do this, but adopting mingw + # and cygwin tools really helped out. + local this_host=unknown + if [ "$OS" == "Windows_NT" ]; then + this_host=$(hostname) + elif [ ! -z "$(echo $MACHTYPE | grep apple)" ]; then + this_host=$(hostname) + elif [ ! -z "$(echo $MACHTYPE | grep suse)" ]; then + this_host=$(hostname --long) + elif [ -x "$(which hostname 2>/dev/null)" ]; then + this_host=$(hostname) + fi + echo "$this_host" + } + + ############## + # NOTE: no more function definitions are allowed after this point. function function_sentinel() diff --git a/scripts/rev_control/version_control.sh b/scripts/rev_control/version_control.sh index 01ca3c56..bd3f960e 100644 --- a/scripts/rev_control/version_control.sh +++ b/scripts/rev_control/version_control.sh @@ -44,21 +44,6 @@ function get_our_hostname() #echo "hostname is $this_host" } -# this function sets a variable called "home_system" to "true" if the -# machine is considered one of fred's home machines. if you are not -# fred, you may want to change the machine choices. -function is_home_system() -{ - # load up the name of the host. - get_our_hostname - # reset the variable that we'll be setting. - unset home_system - export home_system - if [[ $this_host == *.gruntose.blurgh ]]; then - home_system=true - fi -} - #hmmm: move to core. # makes sure that the "folder" is a directory and is writable. # remember that bash successful returns are zeroes... -- 2.34.1