mirror of
https://github.com/pstadler/metrics.sh.git
synced 2025-11-08 21:24:54 -05:00
code cleaup. add disk_usage reporter. add handling for docs(). various tweaks and fixes
This commit is contained in:
@@ -1,19 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
# http://stackoverflow.com/a/1369211/183097
|
||||
copy_function () {
|
||||
declare -F $1 > /dev/null || return 1
|
||||
eval "$(echo "${2}()"; declare -f ${1} | tail -n +2)"
|
||||
}
|
||||
|
||||
is_function () {
|
||||
[ "`type -t $1`" == 'function' ]
|
||||
}
|
||||
|
||||
OS_TYPE=$(case "$OSTYPE" in
|
||||
(solaris*) echo solaris;;
|
||||
(darwin*) echo osx;;
|
||||
(linux*) echo linux;;
|
||||
(bsd*) echo bsd;;
|
||||
(*) echo unknown;;
|
||||
esac)
|
||||
# http://stackoverflow.com/a/1369211/183097
|
||||
copy_function () {
|
||||
declare -F $1 > /dev/null || return 1
|
||||
eval "$(echo "${2}()"; declare -f ${1} | tail -n +2)"
|
||||
}
|
||||
15
lib/utils/os.sh
Normal file
15
lib/utils/os.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
declare -r OS_TYPE=$(case "$OSTYPE" in
|
||||
(solaris*) echo solaris;;
|
||||
(darwin*) echo osx;;
|
||||
(linux*) echo linux;;
|
||||
(bsd*) echo bsd;;
|
||||
(*) echo unknown;;
|
||||
esac)
|
||||
|
||||
is_solaris () { [ $OS_TYPE == 'solaris' ]; }
|
||||
is_osx () { [ $OS_TYPE == 'osx' ]; }
|
||||
is_linux () { [ $OS_TYPE == 'solaris' ]; }
|
||||
is_bsd () { [ $OS_TYPE == 'bsd']; }
|
||||
is_unknown () { [ $OS_TYPE == 'unknown' ]; }
|
||||
Reference in New Issue
Block a user