Skip to content

Commit 9e08c57

Browse files
tks1197kou
andauthored
apacheGH-45050: [CI][Dev] Apply ShellCheck lint to c_glib/test/run-test.sh (apache#45052)
### Rationale for this change ```bash ❯ pre-commit run --show-diff-on-failure --color=always --all-files shellcheck ShellCheck v0.10.0.......................................................Failed - hook id: shellcheck - exit code: 1 In c_glib/test/run-test.sh line 20: test_dir="$(cd $(dirname $0); pwd)" ^--------------^ SC2164 (warning): Use 'cd ... || exit' or 'cd ... || return' in case cd fails. ^-----------^ SC2046 (warning): Quote this to prevent word splitting. ^-- SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: test_dir="$(cd $(dirname "$0") || exit; pwd)" In c_glib/test/run-test.sh line 50: MODULE_TYPELIB_DIR_VAR_NAME="$(echo ${module} | tr a-z- A-Z_)_TYPELIB_DIR" ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: MODULE_TYPELIB_DIR_VAR_NAME="$(echo "${module}" | tr a-z- A-Z_)_TYPELIB_DIR" In c_glib/test/run-test.sh line 77: ${DEBUGGER} "${DEBUGGER_ARGS[@]}" "${RUBY}" ${test_dir}/run-test.rb "$@" ^---------^ SC2086 (info): Double quote to prevent globbing and word splitting. Did you mean: ${DEBUGGER} "${DEBUGGER_ARGS[@]}" "${RUBY}" "${test_dir}"/run-test.rb "$@" For more information: <https://www.shellcheck.net/wiki/SC2046> -- Quote this to prevent word splitt... <https://www.shellcheck.net/wiki/SC2164> -- Use 'cd ... || exit' or 'cd ... |... <https://www.shellcheck.net/wiki/SC2086> -- Double quote to prevent globbing ... ``` ### What changes are included in this PR? - add missing double quotes(SC2046,SC2086) - Use cd ... || exit in case cd fails.(SC2164) ### Are these changes tested? yes ### Are there any user-facing changes? no * GitHub Issue: apache#45050 Lead-authored-by: takaaki.koike <[email protected]> Co-authored-by: Takaaki Koike <[email protected]> Co-authored-by: Sutou Kouhei <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
1 parent 6f65782 commit 9e08c57

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

.pre-commit-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,5 @@ repos:
182182
(
183183
?^ci/scripts/c_glib_build\.sh$|
184184
?^ci/scripts/c_glib_test\.sh$|
185+
?^c_glib/test/run-test\.sh$|
185186
)

c_glib/test/run-test.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# specific language governing permissions and limitations
1818
# under the License.
1919

20-
test_dir="$(cd $(dirname $0); pwd)"
20+
test_dir="$(cd "$(dirname "$0")" && pwd)"
2121
build_dir="$(cd .; pwd)"
2222

2323
modules=(
@@ -47,7 +47,7 @@ if [ "${BUILD}" != "no" ]; then
4747
fi
4848

4949
for module in "${modules[@]}"; do
50-
MODULE_TYPELIB_DIR_VAR_NAME="$(echo ${module} | tr a-z- A-Z_)_TYPELIB_DIR"
50+
MODULE_TYPELIB_DIR_VAR_NAME="$(echo "${module}" | tr a-z- A-Z_)_TYPELIB_DIR"
5151
module_typelib_dir=$(eval "echo \${${MODULE_TYPELIB_DIR_VAR_NAME}}")
5252
if [ -z "${module_typelib_dir}" ]; then
5353
module_typelib_dir="${build_dir}/${module}"
@@ -74,4 +74,4 @@ case "${DEBUGGER}" in
7474
DEBUGGER_ARGS+=(--)
7575
;;
7676
esac
77-
${DEBUGGER} "${DEBUGGER_ARGS[@]}" "${RUBY}" ${test_dir}/run-test.rb "$@"
77+
${DEBUGGER} "${DEBUGGER_ARGS[@]}" "${RUBY}" "${test_dir}"/run-test.rb "$@"

0 commit comments

Comments
 (0)