mirror of
https://github.com/kvz/bash3boilerplate.git
synced 2025-04-23 14:53:34 +00:00
Add __os
magic var
This commit is contained in:
parent
cbe70aa80e
commit
915f858d5e
@ -64,6 +64,7 @@ For more information on SemVer, please visit [http://semver.org](http://semver.o
|
||||
- Enable errexit, nounset and pipefail at the top
|
||||
- More refined colors (thanks @arathai)
|
||||
- Add Changelog
|
||||
- Add `__os` magic var
|
||||
- Add `__base` magic var
|
||||
- Enable long, GNU style options (thanks @zbeekman)
|
||||
|
||||
|
16
main.sh
16
main.sh
@ -59,8 +59,10 @@ EOF
|
||||
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
|
||||
__base="$(basename ${__file} .sh)"
|
||||
|
||||
|
||||
__os="Linux"
|
||||
if [[ "${OSTYPE:-}" == "darwin"* ]]; then
|
||||
__os="OSX"
|
||||
fi
|
||||
|
||||
### Functions
|
||||
#####################################################################
|
||||
@ -221,17 +223,17 @@ fi
|
||||
### Runtime
|
||||
#####################################################################
|
||||
|
||||
if [[ "${OSTYPE:-}" == "darwin"* ]]; then
|
||||
info "You are on OSX"
|
||||
else
|
||||
info "You are on Linux"
|
||||
fi
|
||||
info "__file: ${__file}"
|
||||
info "__dir: ${__dir}"
|
||||
info "__base: ${__base}"
|
||||
info "__os: ${__os}"
|
||||
|
||||
info "arg_f: ${arg_f}"
|
||||
info "arg_d: ${arg_d}"
|
||||
info "arg_v: ${arg_v}"
|
||||
info "arg_h: ${arg_h}"
|
||||
|
||||
# All of these go to STDERR, so you can use STDOUT for piping machine readable information to other software
|
||||
debug "Info useful to developers for debugging the application, not useful during operations."
|
||||
info "Normal operational messages - may be harvested for reporting, measuring throughput, etc. - no action required."
|
||||
notice "Events that are unusual but not error conditions - might be summarized in an email to developers or admins to spot potential problems - no immediate action required."
|
||||
|
@ -1,6 +1,9 @@
|
||||
B3BP:STDIO_REPLACE_DATETIMES
|
||||
{datetime} UTC [35m[ debug][0m cli arg arg_f = () -> {tmpdir}/x
|
||||
{datetime} UTC [32m[ info][0m You are on {os}
|
||||
{datetime} UTC [32m[ info][0m __file: {root}/main.sh
|
||||
{datetime} UTC [32m[ info][0m __dir: {root}
|
||||
{datetime} UTC [32m[ info][0m __base: main
|
||||
{datetime} UTC [32m[ info][0m __os: {os}
|
||||
{datetime} UTC [32m[ info][0m arg_f: {tmpdir}/x
|
||||
{datetime} UTC [32m[ info][0m arg_d: 0
|
||||
{datetime} UTC [32m[ info][0m arg_v: 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user