Skip to content

Commit 47c758a

Browse files
committed
Change exit for return
1 parent 1a92583 commit 47c758a

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

manage-ghar

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ start () {
4141
if ! [[ -d "$runner_path" ]]
4242
then
4343
echo "Runner path not found"
44-
exit 2
44+
return 10
4545
fi
4646

4747
# check if the runner is running
4848
if ! $force && is_running "$state_path"
4949
then
5050
echo "The runner is already running"
51-
exit 2
51+
return 11
5252
fi
5353

5454
# running as a service, see
@@ -64,7 +64,7 @@ start () {
6464
if ! ([[ -x "$runner_command" ]] || type "$runner_command" >/dev/null 2>&1)
6565
then
6666
echo "Runner command $runner_command is invalid"
67-
exit 2
67+
return 12
6868
fi
6969

7070
echo "Starting runner"
@@ -122,9 +122,9 @@ Optional arguments:
122122
-f
123123
Force start even if the runner is running.
124124
-v
125-
Show current version and exit.
125+
Show current version and return.
126126
-h
127-
Show this help message and exit.
127+
Show this help message and return.
128128
129129
Subcommands:
130130
start
@@ -170,11 +170,11 @@ main () {
170170
case $option in
171171
"h")
172172
usage
173-
exit 0
173+
return 0
174174
;;
175175
"v")
176176
show_version
177-
exit 0
177+
return 0
178178
;;
179179
"s")
180180
state_path="$OPTARG"
@@ -188,7 +188,7 @@ main () {
188188
*)
189189
echo "Unknown option $OPTARG"
190190
usage
191-
exit 1
191+
return 1
192192
;;
193193
esac
194194
done
@@ -199,7 +199,7 @@ main () {
199199
then
200200
echo "Missing arguments"
201201
usage
202-
exit 1
202+
return 2
203203
fi
204204

205205
local subcommand="$1"
@@ -220,26 +220,26 @@ main () {
220220
case $subcommand in
221221
"start")
222222
start "$runner_path" "$state_path" "$runner_command" "$force"
223-
exit 0
223+
return 0
224224
;;
225225
"stop")
226226
stop "$state_path"
227-
exit 0
227+
return 0
228228
;;
229229
"restart")
230230
stop "$state_path"
231231
sleep 1
232232
start "$runner_path" "$state_path" "$runner_command" "$force"
233-
exit 0
233+
return 0
234234
;;
235235
"status")
236236
status "$state_path"
237-
exit 0
237+
return 0
238238
;;
239239
*)
240240
echo "Unknown subcommand $subcommand"
241241
usage
242-
exit 1
242+
return 3
243243
;;
244244
esac
245245
}

0 commit comments

Comments
 (0)