Skip to content

Commit 86500ee

Browse files
implement shellcheck changes
1 parent 423d61a commit 86500ee

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

compile.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ executeGradle() {
3030

3131
(
3232
cd revanced-cli
33-
for patch in $(ls ../revanced-cli-patches/*.patch); do
33+
for patch in ../revanced-cli-patches/*.patch; do
3434
git am --no-3way "$patch"
3535
done
3636
)
@@ -41,17 +41,17 @@ git submodule update --checkout
4141

4242
source version.sh
4343

44-
REVANCED_INTEGRATIONS=$(sed -e 's/^v//' <<< "$REVANCED_INTEGRATIONS")
44+
REVANCED_INTEGRATIONS=${REVANCED_INTEGRATIONS#v}
4545
printf -v REVANCED_INTEGRATIONS_DL "$REVANCED_INTEGRATIONS_URL" "$REVANCED_INTEGRATIONS" "$REVANCED_INTEGRATIONS"
46-
REVANCED_PATCHES=$(sed -e 's/^v//' <<< "$REVANCED_PATCHES")
46+
REVANCED_PATCHES=${REVANCED_PATCHES#v}
4747
printf -v REVANCED_PATCHES_DL "$REVANCED_PATCHES_URL" "$REVANCED_PATCHES" "$REVANCED_PATCHES"
4848

4949
for dlurl in "$REVANCED_INTEGRATIONS_DL" "$REVANCED_PATCHES_DL"; do
5050
dlfile="$(basename "$dlurl")"
5151
[ ! -f "$dlfile" ] && wget -c -O "$dlfile" "$dlurl"
5252
done
5353

54-
REVANCED_CLI=$(sed -e 's/^v//' <<< "$REVANCED_CLI")
54+
REVANCED_CLI=${REVANCED_CLI#v}
5555
ln -v -s -f "revanced-cli/build/libs/revancedcli-$REVANCED_CLI-all.jar" "revanced-cli.jar"
5656

5757
PATCHES_LIST=$(java -jar revanced-cli.jar \
@@ -61,11 +61,12 @@ PATCHES_LIST=$(java -jar revanced-cli.jar \
6161
rm -rf magiskmodule/packageversions
6262
mkdir magiskmodule/packageversions
6363
echo '## Supported Packages and Versions' > magiskmodule/supportedversions.md
64-
for package in $(cut -d$'\t' -f1 <<< "$PATCHES_LIST" | sort -u); do
64+
cut -d$'\t' -f1 <<< "$PATCHES_LIST" | sort -u | while IFS= read -r package; do
6565
grep "^$package" <<< "$PATCHES_LIST" | cut -d$'\t' -f2 | tr ',' '\n' | sed -e 's/^ //' -e 's/ $//' -e '/^$/d' | sort -u > magiskmodule/packageversions/"$package"
6666
echo "- **\`$package\`**" >> magiskmodule/supportedversions.md
67+
#shellcheck disable=SC2016
6768
sed 's/^\(.*\)$/`\1`/' < magiskmodule/packageversions/"$package" | tr '\n' '#' | sed -e '/^$/d' -e 's/#$//' -e 's/#/\n/g' | sed -e 's/^/ - /' >> magiskmodule/supportedversions.md
68-
[ $(wc -l < magiskmodule/packageversions/"$package") -gt 0 ] && echo >> magiskmodule/supportedversions.md
69+
[ "$(wc -l < magiskmodule/packageversions/"$package")" -gt 0 ] && echo >> magiskmodule/supportedversions.md
6970
done
7071

7172
java -jar revanced-cli.jar \

magiskmodule/customize.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#!/system/bin/sh
22

3+
#shellcheck disable=SC2154
34
[ "$BOOTMODE" != "true" ] && abort "Please install this module within the Magisk app."
45

5-
export IFS=$'\n'
6-
76
cd "$MODPATH"
87

98
[ ! -f ./version.sh ] && abort "Missing version.sh"
10-
source ./version.sh
9+
. ./version.sh
1110

1211
MAGISKTMP="$(magisk --path)" || MAGISKTMP=/sbin
1312
MIRROR="$MAGISKTMP"/.magisk/mirror
@@ -24,8 +23,8 @@ BLACKLIST="$(findConfigFile revancedrepackaged-blacklist.txt)"
2423

2524
ui_print "- Preparing Patching Process"
2625

27-
[ ! -f aapt2lib/$ARCH/libaapt2.so ] && abort "Failed to locate libaapt2.so for $ARCH"
28-
mv -v aapt2lib/$ARCH/libaapt2.so aapt2
26+
[ ! -f aapt2lib/"$ARCH"/libaapt2.so ] && abort "Failed to locate libaapt2.so for $ARCH"
27+
mv -v aapt2lib/"$ARCH"/libaapt2.so aapt2
2928
rm -r aapt2lib
3029
chmod -v +x aapt2
3130

@@ -34,7 +33,7 @@ chmod -v +x system/bin/revancedcli
3433
mkdir overlay
3534

3635
processPackage() {
37-
local packagename="$1"
36+
packagename="$1"
3837

3938
[ -z "$(pm list packages "$packagename")" ] && return
4039

@@ -44,7 +43,7 @@ processPackage() {
4443

4544
ui_print "- Processing $packagename"
4645

47-
installedpackageversion="$(pm dump $packagename | grep -E '^ *versionName=.*$' | cut -d'=' -f2)"
46+
installedpackageversion="$(pm dump "$packagename" | grep -E '^ *versionName=.*$' | cut -d'=' -f2)"
4847

4948
[ -s packageversions/"$packagename" ] \
5049
&& ! grep -q -F "$installedpackageversion" < packageversions/"$packagename" \
@@ -72,8 +71,8 @@ processPackage() {
7271
}
7372

7473
patchAPK() {
75-
local packagename="$1"
76-
local apkpath="$2"
74+
packagename="$1"
75+
apkpath="$2"
7776
cd "$TMPDIR"
7877

7978
ui_print "- Patching $packagename"
@@ -83,7 +82,6 @@ patchAPK() {
8382
[ -f "$MODPATH"/options/"$packagename".json ] \
8483
&& cp "$MODPATH"/options/"$packagename".json options.json
8584

86-
local optionsconfigfile=""
8785
optionsconfigfile="$(findConfigFile revancedrepackaged-options.json)"
8886
[ -f "$optionsconfigfile" ] \
8987
&& cp "$optionsconfigfile" options.json

magiskmodule/service.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/system/bin/sh
2-
cd $(dirname $0)
2+
cd "$(dirname "$0")"
33

4-
source ./version.sh
4+
. ./version.sh
55

66
logi() {
7-
local msg="ReVancedRepackaged: $1"
7+
msg="ReVancedRepackaged: $1"
88
log -t Magisk "$msg"
99
echo "$msg" >> /cache/magisk.log
1010
}
@@ -19,16 +19,16 @@ MAGISKTMP="$(magisk --path)" || MAGISKTMP=/sbin
1919
MIRROR="$MAGISKTMP"/.magisk/mirror
2020

2121
checkHash() {
22-
local packagename="$1"
23-
local apkpath="$2"
22+
packagename="$1"
23+
apkpath="$2"
2424
[ "$(sha256sum < "$apkpath")" = "$(cat overlay/"$packagename".sha256sum)" ] && return 0
25-
logi "Package $package has changed their base.apk! Removing their overlay, because a repatch is required."
25+
logi "Package $packagename has changed their base.apk! Removing their overlay, because a repatch is required."
2626
rm overlay/"$packagename".*
2727
return 1
2828
}
2929

3030
overlayPackage() {
31-
local packagename="$1"
31+
packagename="$1"
3232
logi "Overlaying $packagename"
3333

3434
overlayapk=$(pwd)/overlay/"$packagename".apk

0 commit comments

Comments
 (0)