- Base library: Add optionnal "FORCE" flag to cmd_exec & sh_exec functions to overstep Test mode,
- Split between rx3-base, rx3-base-config, rx3-base-libs and rx3-base-tools RPM packages.
This commit is contained in:
@@ -161,6 +161,16 @@ echo_error()
|
||||
|
||||
cmd_exec()
|
||||
{
|
||||
local force="FALSE"
|
||||
|
||||
|
||||
if [[ "$1" == "FORCE" ]]
|
||||
then
|
||||
force="TRUE"
|
||||
shift
|
||||
fi
|
||||
|
||||
|
||||
if [[ "${VERBOSE}" == "TRUE" ]]
|
||||
then
|
||||
local caller="${FUNCNAME[1]:-MAIN}"
|
||||
@@ -171,12 +181,12 @@ cmd_exec()
|
||||
echo >&2
|
||||
fi
|
||||
|
||||
if [[ ${DUMP} == "TRUE" ]]
|
||||
if [[ ( "${force}" != "TRUE" ) && ( "${DUMP}" == "TRUE" ) ]]
|
||||
then
|
||||
printf '%q ' "$@"
|
||||
echo
|
||||
else
|
||||
if [[ "${DRY_RUN}" != "TRUE" ]]
|
||||
if [[ ( "${force}" == "TRUE" ) || ( "${DRY_RUN}" != "TRUE" ) ]]
|
||||
then
|
||||
"$@"
|
||||
fi
|
||||
@@ -193,9 +203,19 @@ cmd_exec()
|
||||
|
||||
sh_exec()
|
||||
{
|
||||
local force="FALSE"
|
||||
|
||||
|
||||
if [[ "$1" == "FORCE" ]]
|
||||
then
|
||||
force="TRUE"
|
||||
shift
|
||||
fi
|
||||
|
||||
|
||||
if [[ "$#" -ne 1 ]] || [[ -z "$1" ]]
|
||||
then
|
||||
echo_error "sh_exec expects exactly 1 non empty argument"
|
||||
echo_error "sh_exec expects exactly 1 non empty argument after FORCE optional flag"
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -208,11 +228,11 @@ sh_exec()
|
||||
printf 'bash -c %q\n' "${NAME}" "${caller}" "$1" >&2
|
||||
fi
|
||||
|
||||
if [[ ${DUMP} == "TRUE" ]]
|
||||
if [[ ( "${force}" != "TRUE" ) && ( "${DUMP}" == "TRUE" ) ]]
|
||||
then
|
||||
printf 'bash -c %q\n' "${NAME}" "${caller}" "$1"
|
||||
else
|
||||
if [[ "${DRY_RUN}" != "TRUE" ]]
|
||||
if [[ ( "${force}" == "TRUE" ) || ( "${DRY_RUN}" != "TRUE" ) ]]
|
||||
then
|
||||
bash -o errexit -o pipefail -o nounset -O extglob -c -- "$1" bash
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user