File tree Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -164,21 +164,17 @@ function common::is_hook_run_on_whole_repo {
164
164
# 3. Complete hook execution and return exit code
165
165
# Arguments:
166
166
# hook_id (string) hook ID, see `- id` for details in .pre-commit-hooks.yaml file
167
- # args_array_length (integer) Count of arguments in args array.
168
- # args (array) arguments that configure wrapped tool behavior
167
+ # args (string with array) arguments that configure wrapped tool behavior
169
168
# files (array) filenames to check
170
169
# ######################################################################
171
170
function common::per_dir_hook {
172
171
local -r hook_id=" $1 "
173
- local -i args_array_length=$2
174
- shift 2
172
+ # Expand args to a true array
175
173
local -a args=()
176
- # Expand args to a true array.
177
- # Based on https://stackoverflow.com/a/10953834
178
- while (( args_array_length-- > 0 )) ; do
179
- args+=(" $1 " )
180
- shift
181
- done
174
+ while read -r -d ' ' ARG; do
175
+ args+=(" $ARG " )
176
+ done < <( echo " $2 " | xargs printf ' %s\0' )
177
+ shift 2
182
178
# assign rest of function's positional ARGS into `files` array,
183
179
# despite there's only one positional ARG left
184
180
local -a -r files=(" $@ " )
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ function main {
15
15
# JFYI: suppress color for `tfupdate` is N/A`
16
16
17
17
# shellcheck disable=SC2153 # False positive
18
- common::per_dir_hook " $HOOK_ID " " ${# ARGS[@]} " " ${ARGS[@ ]}" " ${FILES[@]} "
18
+ common::per_dir_hook " $HOOK_ID " " ${ARGS[* ]} " " ${FILES[@]} "
19
19
}
20
20
# ######################################################################
21
21
# Unique part of `common::per_dir_hook`. The function is executed in loop
You can’t perform that action at this time.
0 commit comments