Skip to content

Commit a1a5b5e

Browse files
committed
优化 Shell 脚本导包的写法
1 parent 5aa33b4 commit a1a5b5e

File tree

91 files changed

+825
-701
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+825
-701
lines changed

shell/business/GitSelector.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
# time : 2026/01/25
66
# desc : Git 选择器脚本
77
# ----------------------------------------------------------------------
8-
[ -z "" ] || source "/GitTools.sh"
9-
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/GitTools.sh"
10-
[ -z "" ] || source "../common/FileTools.sh"
11-
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../common/FileTools.sh"
8+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/GitTools.sh" || source "GitTools.sh"
9+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../common/FileTools.sh" || source "../common/FileTools.sh"
1210

1311
selectLocalRepositoryPath() {
1412
echo "请输入 Git 仓库目录路径" >&2

shell/common/FileTools.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
# time : 2026/01/25
66
# desc : 文件路径工具脚本
77
# ----------------------------------------------------------------------
8-
[ -z "" ] || source "/SystemPlatform.sh"
9-
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/SystemPlatform.sh"
10-
[ -z "" ] || source "/EnvironmentTools.sh"
11-
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/EnvironmentTools.sh"
8+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/SystemPlatform.sh" || source "SystemPlatform.sh"
9+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/EnvironmentTools.sh" || source "EnvironmentTools.sh"
1210

1311
getFileSeparator() {
1412
if isWindows; then

shell/common/IpAddressTools.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
# time : 2026/01/25
66
# desc : 剪贴板工具
77
# ----------------------------------------------------------------------
8-
[ -z "" ] || source "/SystemPlatform.sh"
9-
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/SystemPlatform.sh"
10-
[ -z "" ] || source "/EnvironmentTools.sh"
11-
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/EnvironmentTools.sh"
8+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/SystemPlatform.sh" || source "SystemPlatform.sh"
9+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/EnvironmentTools.sh" || source "EnvironmentTools.sh"
1210

1311
isIpV4Format() {
1412
local ip=$1

shell/common/PasteTools.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
# time : 2026/01/25
66
# desc : 剪贴板工具
77
# ----------------------------------------------------------------------
8-
[ -z "" ] || source "/SystemPlatform.sh"
9-
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/SystemPlatform.sh"
10-
[ -z "" ] || source "/EnvironmentTools.sh"
11-
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/EnvironmentTools.sh"
8+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/SystemPlatform.sh" || source "SystemPlatform.sh"
9+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/EnvironmentTools.sh" || source "EnvironmentTools.sh"
1210

1311
copyTextToPaste() {
1412
local copyText

shell/common/ProcessTools.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# time : 2026/01/25
66
# desc : 进程管理工具
77
# ----------------------------------------------------------------------
8-
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/SystemPlatform.sh"
8+
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/SystemPlatform.sh" || source "SystemPlatform.sh"
99

1010
isProcessRunning() {
1111
local processName=$1

shell/common/SystemPlatform.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# time : 2026/01/25
66
# desc : 系统平台脚本(判断 macOS/Windows/Linux)
77
# ----------------------------------------------------------------------
8-
98
getSystemName() {
109
uname -s
1110
}

shell/device-tools/ClearAppData.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
# time : 2026/01/25
66
# desc : 应用数据清除脚本(pm clear 清数据)
77
# ----------------------------------------------------------------------
8-
scriptDirPath=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
9-
[ -z "" ] || source "../common/SystemPlatform.sh"
10-
source "${scriptDirPath}/../common/SystemPlatform.sh"
11-
[ -z "" ] || source "../common/EnvironmentTools.sh"
12-
source "${scriptDirPath}/../common/EnvironmentTools.sh"
13-
[ -z "" ] || source "/../business/DevicesSelector.sh"
14-
source "${scriptDirPath}/../business/DevicesSelector.sh"
8+
scriptDirPath=$(dirname "${BASH_SOURCE[0]}")
9+
originalDirPath=$PWD
10+
cd "${scriptDirPath}" || exit 1
11+
source "../common/SystemPlatform.sh" && \
12+
source "../common/EnvironmentTools.sh" && \
13+
source "../business/DevicesSelector.sh" || exit 1
14+
cd "${originalDirPath}" || exit 1
15+
unset scriptDirPath
16+
unset originalDirPath
1517

1618
waitUserInputParameter() {
1719
echo "请输入要清除数据的应用包名:"

shell/device-tools/ClearGlobalProxy.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
# time : 2026/01/25
66
# desc : adb 清除全局代理脚本
77
# ----------------------------------------------------------------------
8-
scriptDirPath=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
9-
[ -z "" ] || source "../common/SystemPlatform.sh"
10-
source "${scriptDirPath}/../common/SystemPlatform.sh"
11-
[ -z "" ] || source "../common/EnvironmentTools.sh"
12-
source "${scriptDirPath}/../common/EnvironmentTools.sh"
13-
[ -z "" ] || source "/../business/DevicesSelector.sh"
14-
source "${scriptDirPath}/../business/DevicesSelector.sh"
8+
scriptDirPath=$(dirname "${BASH_SOURCE[0]}")
9+
originalDirPath=$PWD
10+
cd "${scriptDirPath}" || exit 1
11+
source "../common/SystemPlatform.sh" && \
12+
source "../common/EnvironmentTools.sh" && \
13+
source "../business/DevicesSelector.sh" || exit 1
14+
cd "${originalDirPath}" || exit 1
15+
unset scriptDirPath
16+
unset originalDirPath
1517

1618
getGlobalProxy() {
1719
local deviceId=$1

shell/device-tools/ConnectWirelessAdb.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
# time : 2026/01/25
66
# desc : 开启无线 adb 调试脚本
77
# ----------------------------------------------------------------------
8-
scriptDirPath=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
9-
[ -z "" ] || source "../common/SystemPlatform.sh"
10-
source "${scriptDirPath}/../common/SystemPlatform.sh"
11-
[ -z "" ] || source "../common/EnvironmentTools.sh"
12-
source "${scriptDirPath}/../common/EnvironmentTools.sh"
13-
[ -z "" ] || source "/../business/DevicesSelector.sh"
14-
source "${scriptDirPath}/../business/DevicesSelector.sh"
8+
scriptDirPath=$(dirname "${BASH_SOURCE[0]}")
9+
originalDirPath=$PWD
10+
cd "${scriptDirPath}" || exit 1
11+
source "../common/SystemPlatform.sh" && \
12+
source "../common/EnvironmentTools.sh" && \
13+
source "../business/DevicesSelector.sh" || exit 1
14+
cd "${originalDirPath}" || exit 1
15+
unset scriptDirPath
16+
unset originalDirPath
1517

1618
waitUserInputParameter() {
1719
echo "请输入设备端无线连接的端口号(可空,默认端口号为 5555):"

shell/device-tools/DisabledApp.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
# author : Android 轮子哥
44
# github : https://github.com/getActivity/AndroidCmdTools
55
# time : 2026/01/25
6-
# desc : adb 冻结脚本(支持多包名冻结和多设备并行冻结
6+
# desc : 应用禁用脚本(禁用系统应用
77
# ----------------------------------------------------------------------
8-
scriptDirPath=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
9-
[ -z "" ] || source "../common/SystemPlatform.sh"
10-
source "${scriptDirPath}/../common/SystemPlatform.sh"
11-
[ -z "" ] || source "../common/EnvironmentTools.sh"
12-
source "${scriptDirPath}/../common/EnvironmentTools.sh"
13-
[ -z "" ] || source "/../business/DevicesSelector.sh"
14-
source "${scriptDirPath}/../business/DevicesSelector.sh"
8+
scriptDirPath=$(dirname "${BASH_SOURCE[0]}")
9+
originalDirPath=$PWD
10+
cd "${scriptDirPath}" || exit 1
11+
source "../common/SystemPlatform.sh" && \
12+
source "../common/EnvironmentTools.sh" && \
13+
source "../business/DevicesSelector.sh" || exit 1
14+
cd "${originalDirPath}" || exit 1
15+
unset scriptDirPath
16+
unset originalDirPath
1517

1618
waitUserInputParameter() {
1719
echo "请输入要冻结应用包名(可输入多个,空格分隔):"

0 commit comments

Comments
 (0)