Skip to content

Commit bc99861

Browse files
committed
fix: Return 1 if sh fails
This should not be necessary because of -e?
1 parent bdc7d57 commit bc99861

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

pkg/lib/do.sh

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,33 @@ do_set() {
2020
# -------------------------- set ------------------------- #
2121
# Source category pre
2222
if [ -f "$db_dir/$category/set-pre.sh" ]; then
23-
sh "$db_dir/$category/set-pre.sh" "$db_dir/$category" "$program"
23+
if ! sh "$db_dir/$category/set-pre.sh" "$db_dir/$category" "$program"; then
24+
return 1
25+
fi
2426
fi
2527

2628
# Source program pre
2729
if [ -f "$db_dir/$category/$program/set-pre.sh" ]; then
28-
sh "$db_dir/$category/$program/set-pre.sh" "$db_dir/$category" "$program"
30+
if ! sh "$db_dir/$category/$program/set-pre.sh" "$db_dir/$category" "$program"; then
31+
return 1
32+
fi
2933
fi
3034

3135
# Actually set
3236
printf "%s" "$program" >| "$db_dir/$category/_.current"
3337

3438
# Source program post
3539
if [ -f "$db_dir/$category/$program/set-post.sh" ]; then
36-
sh "$db_dir/$category/$program/set-post.sh" "$db_dir/$category" "$program"
40+
if ! sh "$db_dir/$category/$program/set-post.sh" "$db_dir/$category" "$program"; then
41+
return 1
42+
fi
3743
fi
3844

3945
# Source category post
4046
if [ -f "$db_dir/$category/set-post.sh" ]; then
41-
sh "$db_dir/$category/set-post.sh" "$db_dir/$category" "$program"
47+
if ! sh "$db_dir/$category/set-post.sh" "$db_dir/$category" "$program"; then
48+
return 1
49+
fi
4250
fi
4351

4452
log.info "Category '$category' defaults to '$program'"
@@ -69,32 +77,40 @@ do_launch() {
6977
# ------------------------ launch ------------------------ #
7078
# Source category pre
7179
if [ -f "$db_dir/$category/launch-pre.sh" ]; then
72-
sh "$db_dir/$category/launch-pre.sh" "$db_dir/$category" "$program"
80+
if ! sh "$db_dir/$category/launch-pre.sh" "$db_dir/$category" "$program"; then
81+
return 1
82+
fi
7383
fi
7484

7585
# Source program pre
7686
if [ -f "$db_dir/$category/$program/launch-pre.sh" ]; then
77-
sh "$db_dir/$category/$program/launch-pre.sh" "$db_dir/$category" "$program"
87+
if ! sh "$db_dir/$category/$program/launch-pre.sh" "$db_dir/$category" "$program"; then
88+
return 1
89+
fi
7890
fi
7991

8092
# Source launch if it exists. If otherwise, infer
8193
# the launch command from the program name
8294
if [ -f "$db_dir/$category/$program/launch.sh" ]; then
8395
if ! sh "$db_dir/$category/$program/launch.sh" "$db_dir/$category" "$program"; then
84-
log.die "$gui" "Source failed"
96+
log.die "$gui" "Source failed" # TODO: fix error message
8597
fi
8698
else
8799
log.die "$gui" "launch.sh for program '$program' does not exist"
88100
fi
89101

90102
# Source program post
91103
if [ -f "$db_dir/$category/$program/launch-post.sh" ]; then
92-
sh "$db_dir/$category/$program/launch-post.sh" "$db_dir/$category" "$program"
104+
if ! sh "$db_dir/$category/$program/launch-post.sh" "$db_dir/$category" "$program"; then
105+
return 1
106+
fi
93107
fi
94108

95109
# Source category post
96110
if [ -f "$db_dir/$category/launch-post.sh" ]; then
97-
sh "$db_dir/$category/launch-post.sh" "$db_dir/$category" "$program"
111+
if ! sh "$db_dir/$category/launch-post.sh" "$db_dir/$category" "$program"; then
112+
return 1
113+
fi
98114
fi
99115
}
100116

0 commit comments

Comments
 (0)