Skip to content

Commit 1c68130

Browse files
committed
2023.07.03:
* fixed: bash/github/print-*.sh: minor fixup * refactor: bash: replaced `[[ ... ]] && { ... }` expressions by `if [[ ... ]]; then ... fi` statement to reduce places with accidental return code change
1 parent d50b1a1 commit 1c68130

31 files changed

+96
-92
lines changed

bash/_common/source-and-call.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# Script can be ONLY executed.
44
[[ -z "$BASH" || (-n "$BASH_LINENO" && BASH_LINENO[0] -gt 0) ]] && return
55

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

1111
# first parameter is source file
1212
if [[ -n "$1" && "$1" != '.' ]]; then

bash/board/accum-stats.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
# This is a composite script to use from a composite GitHub action.
55
#
66

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

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

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

2020

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

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

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

3636
[[ -z "$stats_by_year_dir" ]] && stats_by_year_dir="$stats_dir/by_year"
3737
[[ -z "$stats_json" ]] && stats_json="$stats_dir/latest.json"

bash/cache/accum-content.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
# The rest of variables is related to other scripts.
2020
#
2121

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

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

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

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

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

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

5656
content_index_dir="${content_index_dir%/}"
5757

bash/github/accum-rate-limits.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
# This is a composite script to use from a composite GitHub action.
55
#
66

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

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

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

2121

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

2727
[[ -z "$stats_by_year_dir" ]] && stats_by_year_dir="$stats_dir/by_year"
2828
[[ -z "$stats_json" ]] && stats_json="$stats_dir/latest.json"

bash/github/accum-stats.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
# This is a composite script to use from a composite GitHub action.
55
#
66

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

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

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

2121

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

2727
stat_list_key="$stat_entity"
2828

bash/github/begin-print-annotation-group.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
SOURCE_GHWF_BEGIN_PRINT_ANNOTATION_GROUP_SH=1 # including guard
1111

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

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

bash/github/enable-github-env-autoeval.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
SOURCE_GHWF_ENABLE_GITHUB_ENV_AUTOEVAL_SH=1 # including guard
1111

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

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

bash/github/end-print-annotation-group.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
SOURCE_GHWF_END_PRINT_ANNOTATION_GROUP_SH=1 # including guard
1111

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

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

bash/github/eval-from-args.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
SOURCE_GHWF_EVAL_FROM_ARGS_SH=1 # including guard
1111

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

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

bash/github/flush-print-annotations.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
SOURCE_GHWF_FLUSH_PRINT_ANNOTATIONS_SH=1 # including guard
1111

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

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

bash/github/init-basic-workflow.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444

4545
SOURCE_GHWF_INIT_BASIC_WORKFLOW_SH=1 # including guard
4646

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

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

bash/github/init-curl-workflow.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
SOURCE_GHWF_INIT_CURL_WORKFLOW_SH=1 # including guard
1111

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

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

bash/github/init-diff-workflow.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
SOURCE_GHWF_INIT_DIFF_WORKFLOW_SH=1 # including guard
77

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

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

bash/github/init-github-workflow.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
SOURCE_GHWF_INIT_GITHUB_WORKFLOW_SH=1 # including guard
1111

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

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

bash/github/init-jq-workflow.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
SOURCE_GHWF_INIT_JQ_WORKFLOW_SH=1 # including guard
1111

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

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

bash/github/init-print-workflow.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
SOURCE_GHWF_INIT_PRINT_WORKFLOW_SH=1 # including guard
1111

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

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

bash/github/init-stats-workflow.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,27 @@
99

1010
SOURCE_GHWF_INIT_STATS_WORKFLOW_SH=1 # including guard
1111

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

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

1919

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

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

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

3535
tkl_set_return

bash/github/init-tacklelib-workflow.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
SOURCE_GHWF_INIT_TACKLELIB_WORKFLOW_SH=1 # including guard
1111

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

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

bash/github/init-xq-workflow.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424

2525
SOURCE_GHWF_INIT_XQ_WORKFLOW_SH=1 # including guard
2626

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

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

bash/github/init-yq-workflow.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@
6060

6161
SOURCE_GHWF_INIT_YQ_WORKFLOW_SH=1 # including guard
6262

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

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

bash/github/is-flag-true-in-flags-expr-string.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
SOURCE_GHWF_IS_FLAG_TRUE_IN_FLAGS_EXPR_STRING_SH=1 # including guard
1010

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

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

bash/github/print-error-ln.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
SOURCE_GHWF_PRINT_ERROR_LN_SH=1 # including guard
1111

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

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

0 commit comments

Comments
 (0)