Skip to content

Commit

Permalink
2023.07.03:
Browse files Browse the repository at this point in the history
* fixed: bash/github/print-*.sh: minor fixup
* refactor: bash: replaced `[[ ... ]] && { ... }` expressions by `if [[ ... ]]; then ... fi` statement to reduce places with accidental return code change
  • Loading branch information
andry81 committed Jul 3, 2023
1 parent d50b1a1 commit 1c68130
Show file tree
Hide file tree
Showing 31 changed files with 96 additions and 92 deletions.
4 changes: 2 additions & 2 deletions bash/_common/source-and-call.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# Script can be ONLY executed.
[[ -z "$BASH" || (-n "$BASH_LINENO" && BASH_LINENO[0] -gt 0) ]] && return

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

# first parameter is source file
if [[ -n "$1" && "$1" != '.' ]]; then
Expand Down
16 changes: 8 additions & 8 deletions bash/board/accum-stats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
# This is a composite script to use from a composite GitHub action.
#

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand All @@ -18,20 +18,20 @@ tkl_include_or_abort "$GH_WORKFLOW_ROOT/bash/github/init-curl-workflow.sh"
tkl_include_or_abort "$GH_WORKFLOW_ROOT/bash/github/init-tacklelib-workflow.sh"


[[ -z "$topic_query_url" ]] && {
if [[ -z "$topic_query_url" ]]; then
gh_print_error_ln "$0: error: \`topic_query_url\` variable is not defined."
exit 255
}
fi

[[ -z "$replies_sed_regexp" ]] && {
if [[ -z "$replies_sed_regexp" ]]; then
gh_print_error_ln "$0: error: \`replies_sed_regexp\` variable is not defined."
exit 255
}
fi

[[ -z "$views_sed_regexp" ]] && {
if [[ -z "$views_sed_regexp" ]]; then
gh_print_error_ln "$0: error: \`views_sed_regexp\` variable is not defined."
exit 255
}
fi

[[ -z "$stats_by_year_dir" ]] && stats_by_year_dir="$stats_dir/by_year"
[[ -z "$stats_json" ]] && stats_json="$stats_dir/latest.json"
Expand Down
16 changes: 8 additions & 8 deletions bash/cache/accum-content.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
# The rest of variables is related to other scripts.
#

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand All @@ -38,20 +38,20 @@ tkl_include_or_abort "$GH_WORKFLOW_ROOT/bash/github/utils.sh"
content_config_file="${content_config_file//\\//}"
content_index_file="${content_index_file//\\//}"

[[ -z "$content_config_file" ]] && {
if [[ -z "$content_config_file" ]]; then
gh_print_error_ln "$0: error: \`content_config_file\` variable must be defined."
exit 255
}
fi

[[ ! -f "$content_config_file" ]] && {
if [[ ! -f "$content_config_file" ]]; then
gh_print_error_ln "$0: error: \`content_config_file\` file is not found: \`$content_config_file\`"
exit 255
}
fi

[[ -z "$content_index_file" ]] && {
if [[ -z "$content_index_file" ]]; then
gh_print_error_ln "$0: error: \`content_index_file\` variable must be defined."
exit 255
}
fi

content_index_dir="${content_index_dir%/}"

Expand Down
8 changes: 4 additions & 4 deletions bash/github/accum-rate-limits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
# This is a composite script to use from a composite GitHub action.
#

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand All @@ -19,10 +19,10 @@ tkl_include_or_abort "$GH_WORKFLOW_ROOT/bash/github/init-jq-workflow.sh"
tkl_include_or_abort "$GH_WORKFLOW_ROOT/bash/github/init-tacklelib-workflow.sh"


[[ -z "$stat_entity" ]] && {
if [[ -z "$stat_entity" ]]; then
gh_print_error_ln "$0: error: \`stat_entity\` variable is not defined."
exit 255
}
fi

[[ -z "$stats_by_year_dir" ]] && stats_by_year_dir="$stats_dir/by_year"
[[ -z "$stats_json" ]] && stats_json="$stats_dir/latest.json"
Expand Down
8 changes: 4 additions & 4 deletions bash/github/accum-stats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
# This is a composite script to use from a composite GitHub action.
#

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand All @@ -19,10 +19,10 @@ tkl_include_or_abort "$GH_WORKFLOW_ROOT/bash/github/init-jq-workflow.sh"
tkl_include_or_abort "$GH_WORKFLOW_ROOT/bash/github/init-tacklelib-workflow.sh"


[[ -z "$stat_entity" ]] && {
if [[ -z "$stat_entity" ]]; then
gh_print_error_ln "$0: error: \`stat_entity\` variable is not defined."
exit 255
}
fi

stat_list_key="$stat_entity"

Expand Down
4 changes: 2 additions & 2 deletions bash/github/begin-print-annotation-group.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

SOURCE_GHWF_BEGIN_PRINT_ANNOTATION_GROUP_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand Down
4 changes: 2 additions & 2 deletions bash/github/enable-github-env-autoeval.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

SOURCE_GHWF_ENABLE_GITHUB_ENV_AUTOEVAL_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand Down
4 changes: 2 additions & 2 deletions bash/github/end-print-annotation-group.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

SOURCE_GHWF_END_PRINT_ANNOTATION_GROUP_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand Down
4 changes: 2 additions & 2 deletions bash/github/eval-from-args.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

SOURCE_GHWF_EVAL_FROM_ARGS_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand Down
4 changes: 2 additions & 2 deletions bash/github/flush-print-annotations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

SOURCE_GHWF_FLUSH_PRINT_ANNOTATIONS_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand Down
4 changes: 2 additions & 2 deletions bash/github/init-basic-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@

SOURCE_GHWF_INIT_BASIC_WORKFLOW_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand Down
4 changes: 2 additions & 2 deletions bash/github/init-curl-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

SOURCE_GHWF_INIT_CURL_WORKFLOW_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand Down
4 changes: 2 additions & 2 deletions bash/github/init-diff-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

SOURCE_GHWF_INIT_DIFF_WORKFLOW_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand Down
4 changes: 2 additions & 2 deletions bash/github/init-github-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

SOURCE_GHWF_INIT_GITHUB_WORKFLOW_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand Down
4 changes: 2 additions & 2 deletions bash/github/init-jq-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

SOURCE_GHWF_INIT_JQ_WORKFLOW_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand Down
4 changes: 2 additions & 2 deletions bash/github/init-print-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

SOURCE_GHWF_INIT_PRINT_WORKFLOW_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand Down
16 changes: 8 additions & 8 deletions bash/github/init-stats-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@

SOURCE_GHWF_INIT_STATS_WORKFLOW_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?


[[ -z "$stats_dir" ]] && {
if [[ -z "$stats_dir" ]]; then
gh_print_error_ln "$0: error: \`stats_dir\` variable must be defined."
exit 255
}
fi

[[ ! -d "$stats_dir" ]] && {
if [[ ! -d "$stats_dir" ]]; then
gh_print_error_ln "$0: error: \`stats_dir\` directory is not found: \`$stats_dir\`"
exit 255
}
fi

[[ -n "$stats_json" && ! -f "$stats_json" ]] && {
if [[ -n "$stats_json" && ! -f "$stats_json" ]]; then
gh_print_error_ln "$0: error: \`stats_json\` file is not found: \`$stats_json\`"
exit 255
}
fi

tkl_set_return
4 changes: 2 additions & 2 deletions bash/github/init-tacklelib-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

SOURCE_GHWF_INIT_TACKLELIB_WORKFLOW_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand Down
4 changes: 2 additions & 2 deletions bash/github/init-xq-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

SOURCE_GHWF_INIT_XQ_WORKFLOW_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand Down
4 changes: 2 additions & 2 deletions bash/github/init-yq-workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@

SOURCE_GHWF_INIT_YQ_WORKFLOW_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand Down
4 changes: 2 additions & 2 deletions bash/github/is-flag-true-in-flags-expr-string.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

SOURCE_GHWF_IS_FLAG_TRUE_IN_FLAGS_EXPR_STRING_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand Down
4 changes: 2 additions & 2 deletions bash/github/print-error-ln.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

SOURCE_GHWF_PRINT_ERROR_LN_SH=1 # including guard

[[ -z "$GH_WORKFLOW_ROOT" ]] && {
if [[ -z "$GH_WORKFLOW_ROOT" ]]; then
echo "$0: error: \`GH_WORKFLOW_ROOT\` variable must be defined." >&2
exit 255
}
fi

source "$GH_WORKFLOW_ROOT/_externals/tacklelib/bash/tacklelib/bash_tacklelib" || exit $?

Expand Down
Loading

0 comments on commit 1c68130

Please sign in to comment.