Skip to content

Commit 6713bb9

Browse files
committed
Fix coreutils use on macOS
#121
1 parent 721ff88 commit 6713bb9

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

backup.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,21 @@ fi
3131

3232
# Check if other dependencies are installed: adb, tar, pv, 7z, bc, timeout
3333
# srm is optional so we don't check for it
34-
commands=("tar" "pv" "7z" "adb" "bc" "timeout")
34+
commands=("tar" "pv" "7z" "adb" "bc")
3535

3636
# Add zenity to the list of commands if we're running in WSL
3737
if [ "$(uname -r | sed -n 's/.*\( *Microsoft *\).*/\1/ip')" ]; then
3838
commands+=("zenity")
3939
fi
4040

41+
# Add gtimeout to the list of commands if we're running on macOS
42+
if [ "$(uname)" = "Darwin" ]; then
43+
commands+=("gtimeout")
44+
else
45+
# For the rest of the systems, we use the standard timeout command
46+
commands+=("timeout")
47+
fi
48+
4149
for cmd in "${commands[@]}"
4250
do
4351
# adb is a function in WSL so we're using type instead of command -v

functions/restore_func.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,13 @@ function restore_func() {
6464
timeout 900 ./windows-dependencies/adb/adb.exe install-multiple $apk_files
6565
else
6666
cecho "macOS/Linux detected"
67+
if [[ "$(uname)" == "Darwin" ]]; then
68+
timeout_cmd="gtimeout"
69+
else
70+
timeout_cmd="timeout"
71+
fi
6772
# shellcheck disable=SC2086
68-
timeout 900 adb install-multiple $apk_files
73+
$timeout_cmd 900 adb install-multiple $apk_files
6974
fi
7075
done
7176

@@ -84,8 +89,14 @@ function restore_func() {
8489
done
8590
else
8691
cecho "macOS/Linux detected"
92+
if [[ "$(uname)" == "Darwin" ]]; then
93+
timeout_cmd="gtimeout"
94+
else
95+
timeout_cmd="timeout"
96+
fi
97+
8798
for apk_file in $apk_files; do
88-
timeout 900 adb install "$apk_file"
99+
$timeout_cmd 900 adb install "$apk_file"
89100
done
90101
fi
91102
set -e

0 commit comments

Comments
 (0)