This repository has been archived on 2022-02-20. You can view files and clone it, but cannot push or open issues/pull-requests.
2020-11-13 10:25:04 -08:00
|
|
|
#!/bin/bash
|
|
|
|
# must be json as a string, depends on jq
|
|
|
|
get_prop_value () {
|
|
|
|
local value
|
|
|
|
# echo in $1 get $2
|
|
|
|
value=$(echo $1 | jq -r .$2)
|
|
|
|
echo $value
|
|
|
|
}
|
|
|
|
|
|
|
|
is_array() {
|
|
|
|
local variable_name=$1
|
|
|
|
[[ "$(declare -p $variable_name 2>/dev/null)" =~ "declare -a" ]]
|
|
|
|
}
|
2021-02-05 13:00:57 -08:00
|
|
|
|
|
|
|
filename() {
|
|
|
|
# passed entire path
|
|
|
|
echo $(basename "$1" | rev | cut -f 2- -d '.' | rev)
|
|
|
|
}
|
|
|
|
|
|
|
|
adirname() {
|
|
|
|
# passed entire path
|
|
|
|
echo "$(cd "$(dirname "$1")" >/dev/null 2>&1 ; pwd -P )"
|
|
|
|
}
|
|
|
|
|
2021-02-11 18:29:28 -08:00
|
|
|
chmod_dirs() {
|
|
|
|
# passed entire path
|
|
|
|
local usesudo
|
|
|
|
[[ $1 == -s ]] && usesudo="sudo" && shift 2
|
|
|
|
$usesudo find $1 -type f -exec chmod $2 {} +
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-02-05 13:00:57 -08:00
|
|
|
|