sequencer - fix -c opening config file twice if not existent before

LOG_TIME stamp in local time
This commit is contained in:
2022-11-23 12:14:51 +01:00
parent e464c465a7
commit 5bd33d6a59

View File

@@ -35,6 +35,7 @@ set -o pipefail
readonly seq_origin="$(cd -- "$(dirname -- "$(readlink -f -- "${0}")")" && pwd)" readonly seq_origin="$(cd -- "$(dirname -- "$(readlink -f -- "${0}")")" && pwd)"
readonly seq_file=$(basename -- "${0}") readonly seq_file=$(basename -- "${0}")
readonly seq_fileName=${seq_file%%.*} readonly seq_fileName=${seq_file%%.*}
readonly seq_self="${seq_origin}/${seq_file}"
# shellcheck disable=SC2015 # && || is not if else # shellcheck disable=SC2015 # && || is not if else
readonly seq_invocation="$(printf '%q' "${0}")$( (($#)) && printf ' %q' "$@" || true)" readonly seq_invocation="$(printf '%q' "${0}")$( (($#)) && printf ' %q' "$@" || true)"
readonly seq_template="seqTemplate.sh" readonly seq_template="seqTemplate.sh"
@@ -436,9 +437,9 @@ USAGE_API
if ! (( direct )) ; then if ! (( direct )) ; then
if [[ -n "${LOG_TIME}" ]] ; then if [[ -n "${LOG_TIME}" ]] ; then
if (( appendText )) ; then if (( appendText )) ; then
printf '%24s' "" >${outp} printf '%19s' "" >${outp}
else else
printf '%s ' "$(date -u +"%Y-%m-%d %H:%M:%S UTC")" >${outp} printf '%s' "$(date +"%Y-%m-%d %H:%M:%S")" >${outp}
fi fi
fi fi
@@ -446,7 +447,7 @@ USAGE_API
printf " %3s " "[${log_level}]" >${outp} printf " %3s " "[${log_level}]" >${outp}
printf "%s" "${log_line}" >${outp} printf "%s" "${log_line}" >${outp}
else else
# +3 : "[] " # +4 : " [] "
printf "%$((${#log_level} + 4))s%s" "" "${log_line}" >${outp} printf "%$((${#log_level} + 4))s%s" "" "${log_line}" >${outp}
fi fi
else else
@@ -1300,7 +1301,8 @@ initSeqConfig() {
if [ $retVal -eq 255 ]; then if [ $retVal -eq 255 ]; then
error "No seq configuration created" error "No seq configuration created"
retVal=3 retVal=3
elif ! quiet && ! dry ; then elif interactive && ! dry && (( ! _seq_configEdit )) ; then
# ! _seq_configEdit : Edit operation will be performed in main
if confirm "Edit configuration file now?" ; then if confirm "Edit configuration file now?" ; then
exe editor "$configLoc" exe editor "$configLoc"
. "$configLoc" . "$configLoc"
@@ -1623,10 +1625,10 @@ sqr::main() {
# Create/edit configuration file # Create/edit configuration file
if (( _seq_configEdit )) ; then if (( _seq_configEdit )) ; then
# Suppress seq_config output for editing # Suppress seq_config output for editing and allow it to fail
quietSave=${LOG_LEVEL} quietSave=${LOG_LEVEL}
LOG_LEVEL=0 LOG_LEVEL=0
seq_config "${seq_args[@]}" seq_config "${seq_args[@]}" || true
LOG_LEVEL=${quietSave} LOG_LEVEL=${quietSave}
if [ -w "$seq_configFile" ]; then if [ -w "$seq_configFile" ]; then
exe editor "$seq_configFile" exe editor "$seq_configFile"