code cleaup. add disk_usage reporter. add handling for docs(). various tweaks and fixes

This commit is contained in:
Patrick Stadler
2015-02-22 20:45:57 +01:00
parent 8957cb4387
commit bd037022ad
9 changed files with 114 additions and 44 deletions

View File

@@ -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
View 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' ]; }