mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
30 lines
406 B
Plaintext
30 lines
406 B
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
# wrapper for 'sed -i': fail if file was not modified by sed
|
||
|
|
||
|
set -ueo pipefail
|
||
|
|
||
|
HASHTOOL="sha1sum"
|
||
|
|
||
|
if [[ $# -lt 1 ]]
|
||
|
then
|
||
|
echo "Error: No file given."
|
||
|
echo
|
||
|
exit 1
|
||
|
fi >&2
|
||
|
|
||
|
# get last argument
|
||
|
FILE=${*: -1}
|
||
|
|
||
|
OLD=$(${HASHTOOL} "${FILE}")
|
||
|
sed "$@"
|
||
|
NEW=$(${HASHTOOL} "${FILE}")
|
||
|
|
||
|
# fail if file was not modified
|
||
|
if [[ ${OLD} == "${NEW}" ]]
|
||
|
then
|
||
|
echo "Error: sed $*"
|
||
|
exit 1
|
||
|
fi >&2
|
||
|
exit 0
|