Skip to content

Commit 4a679ca

Browse files
committed
Fixes bug caused by code not being wrapped in a function
Fixes issues #1
1 parent 4068b55 commit 4a679ca

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

src/git-split-file.sh

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ fullUsage() {
259259
#
260260
# ------------------------------------------------------------------------------
261261
handleParams() {
262-
263262
local iDebugLevel sParam sRootFile sSplitDirectory
264263

265264
iDebugLevel=0
@@ -568,7 +567,6 @@ runCleanup() {
568567
}
569568

570569
printHeader() {
571-
572570
printMessage " running $(basename $0)"
573571
printMessage " for source file ${g_sSourceFilePath}"
574572
printMessage " with source directory ${g_sSplitDirectory}"
@@ -628,7 +626,6 @@ run() {
628626
}
629627

630628
finish() {
631-
632629
if [[ ! "${bFinished:-}" ]];then
633630

634631
readonly bFinished=true
@@ -679,25 +676,35 @@ registerDebugTrap() {
679676
# ==============================================================================
680677
# RUN LOGIC
681678
# ------------------------------------------------------------------------------
682-
export PS4='$(printf "%04d: " $LINENO)'
679+
git-split-file() {
680+
export PS4='$(printf "%04d: " $LINENO)'
683681

684-
registerTraps
682+
registerTraps
685683

686-
handleParams "${@}"
684+
handleParams "${@}"
687685

688-
registerDebugTrap
686+
registerDebugTrap
689687

690-
if [[ "${DEBUG_LEVEL}" -gt 2 ]];then
691-
set -o xtrace # Similar to -v, but expands commands, same as "set -x"
692-
fi
688+
if [[ "${DEBUG_LEVEL}" -gt 2 ]];then
689+
set -o xtrace # Similar to -v, but expands commands, same as "set -x"
690+
fi
693691

694-
if [[ ${g_iExitCode} -eq 0 ]];then
692+
if [[ ${g_iExitCode} -eq 0 ]];then
695693

696-
if [[ "${g_bShowHelp}" = true ]];then
697-
fullUsage
698-
else
699-
run
694+
if [[ "${g_bShowHelp}" = true ]];then
695+
fullUsage
696+
else
697+
run
698+
fi
700699
fi
700+
}
701+
702+
if [ "${BASH_SOURCE[0]}" != "$0" ]; then
703+
export -f git-split-file
704+
else
705+
git-split-file "${@}"
706+
exit $?
701707
fi
702708
# ==============================================================================
709+
703710
#EOF

0 commit comments

Comments
 (0)