File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,20 @@ while [[ $# -gt 0 ]]; do
6565 shift || true # ignore error when there are no more arguments
6666done
6767
68+ exit_failed () {
69+ case " $0 " in
70+ * /sh) return 1 ;; # Script is sourced
71+ * ) exit 1 ;; # Script is executed directly
72+ esac
73+ }
74+
75+ exit_successful () {
76+ case " $0 " in
77+ * /sh) return 0 ;; # Script is sourced
78+ * ) exit 0 ;; # Script is executed directly
79+ esac
80+ }
81+
6882if ${readonlyMode} ; then
6983 echo -e " ${COLOR_INFO} detectChangedFiles: Readonly mode activated. Change detection file won't be created.${COLOR_DEFAULT} " >&2
7084else
7488# Check if the paths parameter exist
7589if [ -z " ${paths} " ] ; then
7690 echo 0 # 0=No change detected. The path list is empty. There is nothing to compare. Therefore assume that there are no changes.
77- exit 0
78- fi
91+ exit_successful
92+ fi
7993
8094# Check all paths if they are valid files or valid directories
8195for path in ${paths// ,/ } ; do
@@ -87,7 +101,7 @@ for path in ${paths//,/ }; do
87101 fi
88102 # Neither a valid directory and file
89103 echo -e " ${COLOR_ERROR} detectChangedFiles: Error: Invalid path: ${path}${COLOR_DEFAULT} " >&2
90- exit 1
104+ exit_failed
91105done
92106
93107# Function to get file size
@@ -157,7 +171,7 @@ if [ ! -f "${hashFilePath}" ] ; then
157171 echo -e " ${COLOR_INFO} detectChangedFiles: Skipping file creation with content (=hash) ${CURRENT_FILES_HASH}${COLOR_DEFAULT} " >&2
158172 fi
159173 echo 1 # 1=Change detected and change detection file created
160- exit 0
174+ exit_successful
161175fi
162176
163177# Assume that there is no change if the saved hash is equal to the current one.
You can’t perform that action at this time.
0 commit comments