Skip to content

Commit 7f0b77a

Browse files
committed
解决部分 Shell 脚本出现代码警告的问题
1 parent d49b723 commit 7f0b77a

File tree

3 files changed

+44
-22
lines changed

3 files changed

+44
-22
lines changed

shell/business/ResourceManager.sh

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,34 @@ source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../common/SystemPlatform.s
99
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../common/FileTools.sh" || source "../common/FileTools.sh"
1010

1111
getDexToJarShellDirPath() {
12-
local resourcesDirPath=$(getResourcesDirPath)
12+
local resourcesDirPath
13+
resourcesDirPath=$(getResourcesDirPath)
1314
echo "${resourcesDirPath}$(getFileSeparator)dex2jar-2.4$(getFileSeparator)d2j-dex2jar.sh"
1415
}
1516

1617
getDexToJarShellFilePath() {
17-
local resourcesDirPath=$(getResourcesDirPath)
18+
local resourcesDirPath
19+
resourcesDirPath=$(getResourcesDirPath)
1820
echo "${resourcesDirPath}$(getFileSeparator)dex2jar-2.4$(getFileSeparator)d2j-dex2jar.sh"
1921
}
2022

2123
getJarToDexShellDirPath() {
22-
local resourcesDirPath=$(getResourcesDirPath)
24+
local resourcesDirPath
25+
resourcesDirPath=$(getResourcesDirPath)
2326
echo "${resourcesDirPath}$(getFileSeparator)dex2jar-2.4$(getFileSeparator)d2j-jar2dex.sh"
2427
}
2528

2629
getJarToDexShellFilePath() {
27-
local resourcesDirPath=$(getResourcesDirPath)
30+
local resourcesDirPath
31+
resourcesDirPath=$(getResourcesDirPath)
2832
echo "${resourcesDirPath}$(getFileSeparator)dex2jar-2.4$(getFileSeparator)d2j-jar2dex.sh"
2933
}
3034

3135
getJadxShellFilePath() {
32-
local resourcesDirPath=$(getResourcesDirPath)
33-
local fileSeparator=$(getFileSeparator)
36+
local resourcesDirPath
37+
resourcesDirPath=$(getResourcesDirPath)
38+
local fileSeparator
39+
fileSeparator=$(getFileSeparator)
3440
local jadxVersion="1.5.3"
3541
local jadxDirPath="${resourcesDirPath}${fileSeparator}jadx-${jadxVersion}"
3642

@@ -100,8 +106,10 @@ getJadxShellFilePath() {
100106
}
101107

102108
getJetifierStandaloneShellFilePath() {
103-
local resourcesDirPath=$(getResourcesDirPath)
104-
local fileSeparator=$(getFileSeparator)
109+
local resourcesDirPath
110+
resourcesDirPath=$(getResourcesDirPath)
111+
local fileSeparator
112+
fileSeparator=$(getFileSeparator)
105113
local jetifierDirPath="${resourcesDirPath}${fileSeparator}jetifier-standalone-20200827"
106114
local shellPath="${jetifierDirPath}${fileSeparator}bin${fileSeparator}jetifier-standalone"
107115
if isWindows; then
@@ -115,25 +123,29 @@ getJetifierStandaloneShellFilePath() {
115123
}
116124

117125
getADBKeyBoardApkFilePath() {
118-
local resourcesDirPath=$(getResourcesDirPath)
126+
local resourcesDirPath
127+
resourcesDirPath=$(getResourcesDirPath)
119128
echo "${resourcesDirPath}$(getFileSeparator)ADBKeyBoard-5.0.apk"
120129
}
121130

122131
getApksignerJarFilePath() {
123-
local resourcesDirPath=$(getResourcesDirPath)
132+
local resourcesDirPath
133+
resourcesDirPath=$(getResourcesDirPath)
124134
echo "${resourcesDirPath}$(getFileSeparator)apksigner-36.0.0.jar"
125135
}
126136

127137
getDefaultStoreFilePath() {
128-
local resourcesDirPath=$(getResourcesDirPath)
138+
local resourcesDirPath
139+
resourcesDirPath=$(getResourcesDirPath)
129140
echo "${resourcesDirPath}$(getFileSeparator)signatureFile$(getFileSeparator)AppSignature.jks"
130141
}
131142

132143
getApktoolJarFilePath() {
133144
local resourcesDirPath
134145
resourcesDirPath=$(getResourcesDirPath)
135146
local apktoolVersion="3.0.1"
136-
local jarFilePath="${resourcesDirPath}$(getFileSeparator)apktool-${apktoolVersion}.jar"
147+
local jarFilePath
148+
jarFilePath="${resourcesDirPath}$(getFileSeparator)apktool-${apktoolVersion}.jar"
137149
local expectedSha256="b947b945b4bc455609ba768d071b64d9e63834079898dbaae15b67bf03bcd362"
138150
local actualSha256
139151
if [[ -f "${jarFilePath}" ]]; then
@@ -164,30 +176,35 @@ getApktoolJarFilePath() {
164176
}
165177

166178
getBaksmaliJarFilePath() {
167-
local resourcesDirPath=$(getResourcesDirPath)
179+
local resourcesDirPath
180+
resourcesDirPath=$(getResourcesDirPath)
168181
echo "${resourcesDirPath}$(getFileSeparator)baksmali-2.5.2.jar"
169182
}
170183

171184
getSmaliJarFilePath() {
172-
local resourcesDirPath=$(getResourcesDirPath)
185+
local resourcesDirPath
186+
resourcesDirPath=$(getResourcesDirPath)
173187
echo "${resourcesDirPath}$(getFileSeparator)smali-2.5.2.jar"
174188
}
175189

176190
getDiffuserJarFilePath() {
177-
local resourcesDirPath=$(getResourcesDirPath)
191+
local resourcesDirPath
192+
resourcesDirPath=$(getResourcesDirPath)
178193
echo "${resourcesDirPath}$(getFileSeparator)diffuse-0.1.0.jar"
179194
}
180195

181196
getJdGuiJarFilePath() {
182-
local resourcesDirPath=$(getResourcesDirPath)
197+
local resourcesDirPath
198+
resourcesDirPath=$(getResourcesDirPath)
183199
echo "${resourcesDirPath}$(getFileSeparator)jd-gui-1.6.6.jar"
184200
}
185201

186202
getBundletoolJarFilePath() {
187203
local resourcesDirPath
188204
resourcesDirPath=$(getResourcesDirPath)
189205
local bundletoolVersion="1.18.3"
190-
local jarFilePath="${resourcesDirPath}$(getFileSeparator)bundletool-${bundletoolVersion}.jar"
206+
local jarFilePath
207+
jarFilePath="${resourcesDirPath}$(getFileSeparator)bundletool-${bundletoolVersion}.jar"
191208
local expectedSha256="a099cfa1543f55593bc2ed16a70a7c67fe54b1747bb7301f37fdfd6d91028e29"
192209
local actualSha256
193210
if [[ -f "${jarFilePath}" ]]; then

shell/device-tools/InstallApp.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ installApksWithBundletool() {
8181
baseName=$(basename "${apksFilePath}")
8282
echo "⏳ [${deviceId}] 设备正在安装 [${baseName}]"
8383
local outputPrint
84-
local javaMajorVersionCode=$(getJavaMajorVersionCode)
84+
local javaMajorVersionCode
85+
javaMajorVersionCode=$(getJavaMajorVersionCode)
8586
if (( javaMajorVersionCode <= 11 )); then
86-
local tempDirPath=$(unzipFileToTempDir "${apksFilePath}")
87+
local tempDirPath
88+
tempDirPath=$(unzipFileToTempDir "${apksFilePath}")
8789
local -a apkList=()
8890
while IFS= read -r -d '' apk; do apkList+=("${apk}"); done < <(findApkPathForDir "${tempDirPath}")
8991
outputPrint=$(adb -s "${deviceId}" install-multiple -r "${apkList[@]}" < /dev/null 2>&1)
@@ -112,7 +114,8 @@ installMultipleApkFromDir() {
112114
local baseName
113115
baseName=$(basename "${targetApkFilePath}")
114116
echo "⏳ [${deviceId}] 设备正在安装 [${baseName}]"
115-
local outputPrint=$(adb -s "${deviceId}" install-multiple -r "${apkList[@]}" < /dev/null 2>&1)
117+
local outputPrint
118+
outputPrint=$(adb -s "${deviceId}" install-multiple -r "${apkList[@]}" < /dev/null 2>&1)
116119
local exitCode=$?
117120
if (( exitCode == 0 )); then
118121
echo "✅ [${deviceId}] 设备安装 [${baseName}] 成功"
@@ -201,7 +204,8 @@ installMultipleApk() {
201204
elif [[ "${filePath}" =~ \.apks$ ]]; then
202205
installApksWithBundletool "${deviceId}" "${filePath}"
203206
elif [[ "${filePath}" =~ \.(xapk|apkm)$ ]]; then
204-
local tempDirPath=$(unzipFileToTempDir "${filePath}")
207+
local tempDirPath
208+
tempDirPath=$(unzipFileToTempDir "${filePath}")
205209
if [[ "${filePath}" =~ \.xapk$ ]]; then
206210
maybePushObb "${deviceId}" "${tempDirPath}"
207211
fi

shell/package-tools/AabToApks.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ waitUserInputParameter() {
7171
main() {
7272
checkJavaElevenEnvironment
7373
waitUserInputParameter "$1"
74-
local apksFilePath="$(dirname "${aabFilePath}")/$(basename "${aabFilePath}" .aab).apks"
74+
local apksFilePath
75+
apksFilePath="$(dirname "${aabFilePath}")/$(basename "${aabFilePath}" .aab).apks"
7576
apksFileSuffix="-$(date "+%Y%m%d%H%M%S")"
7677
if [[ -f "${apksFilePath}" ]]; then
7778
apksFilePath="${apksFilePath%.*}${apksFileSuffix}.${apksFilePath##*.}"

0 commit comments

Comments
 (0)