2021-07-21 16:49:00 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#All common functions can be added to this file
|
|
|
|
|
2022-08-16 07:51:45 -04:00
|
|
|
exists() { type -t "$1" > /dev/null 2>&1; }
|
|
|
|
|
2021-07-21 16:49:00 -04:00
|
|
|
is_gnu_sed () {
|
|
|
|
sed --version >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
|
|
|
replace () {
|
2022-06-05 15:30:23 -04:00
|
|
|
echo "${1}"
|
2021-07-21 16:49:00 -04:00
|
|
|
if is_gnu_sed; then
|
2022-06-05 15:30:23 -04:00
|
|
|
sed -i -E "${1}" "${2}"
|
2021-07-21 16:49:00 -04:00
|
|
|
else
|
2022-06-05 15:30:23 -04:00
|
|
|
sed -i '' -E "${1}" "${2}"
|
2021-07-21 16:49:00 -04:00
|
|
|
fi
|
|
|
|
}
|
2022-08-16 07:51:45 -04:00
|
|
|
|
|
|
|
if ! exists gsed; then
|
|
|
|
if is_gnu_sed; then
|
|
|
|
function gsed() {
|
|
|
|
sed -i -E "$@"
|
|
|
|
}
|
|
|
|
else
|
|
|
|
function gsed() {
|
|
|
|
sed -i '' -E "$@"
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
fi
|