2015-03-15 14:55:36 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2015-03-08 20:37:56 +01:00
|
|
|
is_number () {
|
2015-03-15 14:55:36 +01:00
|
|
|
[ ! -z "$1" ] && printf '%f' "$1" > /dev/null 2>&1
|
2015-03-08 20:37:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
iso_date () {
|
|
|
|
date -u +"%Y-%m-%dT%H:%M:%SZ"
|
2015-03-15 14:55:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
in_array () {
|
2015-03-15 17:18:27 +01:00
|
|
|
echo " $2 " | grep -q " $1 "
|
2015-03-15 14:55:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
trim () {
|
|
|
|
echo $1 | sed -e 's/^[[:space:]]*//g' -e 's/[[:space:]]*\$//g'
|
2015-03-21 16:50:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
unique_id () {
|
|
|
|
RESTORE_LC_ALL=$LC_ALL
|
|
|
|
LC_ALL=C
|
|
|
|
echo __u_$(cat /dev/urandom | tr -dc 'A-Za-z0-9' | head -c 10)
|
|
|
|
LC_ALL=$RESTORE_LC_ALL
|
2015-03-21 21:19:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
print_prefixed () {
|
2015-03-22 20:03:10 +01:00
|
|
|
printf "$2\n" | sed -e "s/^/$1/g"
|
2015-03-22 13:55:14 +01:00
|
|
|
}
|