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