Compare commits
4 Commits
b821d4dfa7
...
master
Author | SHA1 | Date | |
---|---|---|---|
308063a3bf | |||
d524d0aabf | |||
018cb9910c | |||
f7d580ea8f |
19
README.md
Normal file
19
README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# BASH Libs
|
||||
This is just a simple bash project of bash code that can be loaded in like you would load in a module in python or ruby
|
||||
|
||||
## How to include them?
|
||||
All you have to do to begin using the libs is source the imports lib (/path/to/import.sh) and it will handle the logic of sourcing the others relative to itself without the user needing to provide anything.
|
||||
|
||||
Example Script:
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
. /path/to/import.sh
|
||||
import config
|
||||
|
||||
load_config_ini /path/to/config.ini
|
||||
|
||||
for KEY in ${!CONFIG[@]}; do
|
||||
echo "$KEY = ${CONFIG[$KEY]}"
|
||||
done
|
||||
```
|
@@ -1,5 +1,5 @@
|
||||
# A variable to contain the configs provided manually or via function calls
|
||||
declare -A CONFIG
|
||||
declare -g -A CONFIG
|
||||
|
||||
##########################
|
||||
# Function: load_section
|
||||
@@ -71,7 +71,7 @@ function load_config_ini () {
|
||||
local -n CONFIG_VAR=${2}
|
||||
|
||||
else
|
||||
local -n CONFIG_VAR="CONFIG"
|
||||
local -n CONFIG_VAR=CONFIG
|
||||
fi
|
||||
|
||||
if ! declare -p ${!CONFIG_VAR} 2>/dev/null | grep -q 'declare -A'; then
|
||||
|
@@ -1,4 +1,4 @@
|
||||
declare LIB_PATH=/opt/bash-lib/
|
||||
declare LIB_PATH=$( dirname $( readlink -f ${BASH_SOURCE[0]} ) )
|
||||
|
||||
########################
|
||||
# Function: dep_exists
|
||||
|
@@ -4,7 +4,7 @@
|
||||
# [$FUNCNAME]="string of varnames"
|
||||
#
|
||||
# It will keep track of vars seperately of each function that log will be used with
|
||||
declare -A LOG_WATCH_VARS
|
||||
declare -g -A LOG_WATCH_VARS
|
||||
|
||||
|
||||
######################
|
||||
|
Reference in New Issue
Block a user