Skip to content

Commit 0ed0ddf

Browse files
committed
scripts/service: fix dynamic desc
- set total to 0 when $REMOVE_LIST does not exist - fix pluralization
1 parent decac66 commit 0ed0ddf

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

module/service.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,22 @@ create_applist() {
7777
# base description
7878
string="description=WebUI-based debloater and whiteout creator"
7979

80-
# count nuked apps
81-
total=$(grep -c '"package_name":' "$REMOVE_LIST")
82-
string="$string | 💥 nuked: $total app$( [ "$total" -lt 2 ] && echo '' || echo 's' )"
80+
# count nuked apps (fallback to 0 if file missing or grep fails)
81+
if [ -f "$REMOVE_LIST" ]; then
82+
total=$(grep -c '"package_name":' "$REMOVE_LIST")
83+
else
84+
total=0
85+
fi
86+
87+
# fallback if grep somehow returns blank
88+
[ -z "$total" ] && total=0
89+
90+
# pluralize
91+
suffix=""
92+
[ "$total" -ne 1 ] && suffix="s"
93+
94+
# add nuked app count
95+
string="$string | 💥 nuked: $total app$suffix"
8396

8497
# detect mount mode
8598
if [ "$use_mountify_script" = true ]; then
@@ -88,8 +101,8 @@ else
88101
string="$string | ⚙️ mount mode: default"
89102
fi
90103

91-
# set module desc
92-
sed -i "s/^description=.*/$string/g" $MODDIR/module.prop
104+
# set module description
105+
sed -i "s/^description=.*/$string/g" "$MODDIR/module.prop"
93106

94107
# wait for boot completed
95108
until [ "$(getprop sys.boot_completed)" = "1" ]; do

0 commit comments

Comments
 (0)