If a user were to `make build` Rook, and after the Ceph CSV was generated and before make had finished, the Rook repo would be left with changes caused by the build modifying files temporarily in-place. All CSV template generation in the Ceph makefile is now self-contained and can be configured to operate outside of the main repo so that files are not modified in-place. In-place modification of files was also incorrect. On Mac some files with `-e` trailing were left, and in-place backups were also present in the form `<filename>''`. Therefore, also fix the generation to fix in-place modifications. Signed-off-by: Blaine Gardner <blaine.gardner@redhat.com>
27 lines
700 B
Bash
Executable File
27 lines
700 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -eEuo pipefail
|
|
|
|
# sed is NOT portable across OSes
|
|
|
|
# sed -i '' does in-place on Mac, BSD, and other POSIX-compliant OSes
|
|
# sed -i '' does not work with GNU sed, but sed -i (without small quotes) does
|
|
|
|
# assume that sed is not GNU sed initially
|
|
SED=(sed -i '')
|
|
|
|
if sed --help &>/dev/null; then
|
|
# if sed doesn't have help text, it isn't GNU sed
|
|
if [[ $(sed --help 2>&1) == *GNU* ]]; then
|
|
SED=(sed -i)
|
|
fi
|
|
fi
|
|
|
|
# sed -e is required on Mac/BSD if the -i option is used
|
|
# sed -e is not required but is supported by GNU sed
|
|
# Therefore, this script supplies -e it unless the first argument to this script is a flag
|
|
if [[ $1 != -* ]]; then
|
|
SED+=(-e)
|
|
fi
|
|
|
|
"${SED[@]}" "${@}"
|