Skip to content

Commit fc3fcdc

Browse files
committed
fix(init): address shellcheck recommendations
1 parent d82e6ef commit fc3fcdc

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

commands/inits/data/git_wrapper.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ unset -f git > /dev/null 2>&1
99
SCMPUFF_GIT_CMD=${SCMPUFF_GIT_CMD:-"$(\which git)"}
1010
export SCMPUFF_GIT_CMD
1111

12-
function git() {
12+
git() {
1313
case $1 in
1414
commit|blame|log|rebase|merge)
1515
scmpuff exec -- "$SCMPUFF_GIT_CMD" "$@";;

commands/inits/data/status_shortcuts.sh

+11-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ scmpuff_status() {
99
# Run scmpuff status, store output
1010
# (`local` needs to be on its own line otherwise exit code is swallowed!)
1111
local cmd_output
12-
cmd_output="$(/usr/bin/env scmpuff status --filelist $@)"
12+
cmd_output=$(/usr/bin/env scmpuff status --filelist "$@")
1313

1414
# if there was an error, exit prematurely, and pass along the exit code
1515
# (STDOUT was swallowed but not STDERR, so user should still see error msg)
@@ -19,17 +19,19 @@ scmpuff_status() {
1919
fi
2020

2121
# Fetch list of files (from first line of script output)
22+
local files
2223
files="$(echo "$cmd_output" | head -n 1)"
2324

2425
# Export numbered env variables for each file
2526
scmpuff_clear_vars
26-
IFS=$'\t'
27+
IFS=$(printf '\t')
2728
local e=1
29+
local file
2830
for file in $files; do
2931
export $scmpuff_env_char$e="$file"
30-
let e++
32+
e=$((e+1))
3133
done
32-
IFS=$' \t\n'
34+
IFS=$(printf ' \t\n')
3335

3436
# Print status (from line two onward)
3537
echo "$cmd_output" | tail -n +2
@@ -42,14 +44,14 @@ scmpuff_status() {
4244
# Clear numbered env variables
4345
scmpuff_clear_vars() {
4446
local scmpuff_env_char="e"
45-
local i
46-
47-
for (( i=1; i<=999; i++ )); do
48-
local env_var_i=${scmpuff_env_char}${i}
49-
if [[ -n ${env_var_i} ]]; then
47+
local i=0
48+
while [ $i -le 999 ]; do
49+
env_var_i=${scmpuff_env_char}${i}
50+
if [ -n "$env_var_i" ]; then
5051
unset ${env_var_i}
5152
else
5253
break
5354
fi
55+
i=$((i+1))
5456
done
5557
}

features/command_init.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Feature: init command
2626

2727
Scenario Outline: --wrap controls git cmd wrapping in output (default: yes)
2828
When I successfully run `scmpuff init <flags>`
29-
Then the output <should?> contain "function git()"
29+
Then the output <should?> contain "git() {"
3030
Examples:
3131
| flags | should? |
3232
| -s | should |

0 commit comments

Comments
 (0)