Skip to content

Commit c955b10

Browse files
committed
fix(init): address shellcheck recommendations
1 parent 7cef3a8 commit c955b10

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

commands/inits/data/git_wrapper.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ unalias git > /dev/null 2>&1
66
unset -f git > /dev/null 2>&1
77

88
# Use the full path to git to avoid infinite loop with git function
9-
export SCMPUFF_GIT_CMD="$(\which git)"
9+
SCMPUFF_GIT_CMD="$(\which git)"
10+
export SCMPUFF_GIT_CMD
1011

1112
# Wrap git with the 'hub' github wrapper, if installed
1213
if type hub > /dev/null 2>&1; then export SCMPUFF_GIT_CMD="hub"; fi
1314

14-
function git() {
15+
git() {
1516
case $1 in
1617
commit|blame|log|rebase|merge)
1718
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
@@ -21,7 +21,7 @@ Feature: init command
2121

2222
Scenario Outline: --wrap controls git cmd wrapping in output (default: yes)
2323
When I successfully run `scmpuff init <flags>`
24-
Then the output <should?> contain "function git()"
24+
Then the output <should?> contain "git() {"
2525
Examples:
2626
| flags | should? |
2727
| -s | should |

0 commit comments

Comments
 (0)