1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 11:07:44 +00:00

util/android-commands: Fix shellcheck warnings. Reformat file.

This commit is contained in:
Joining7943 2023-04-16 13:33:56 +02:00
parent 19add3a4bd
commit f155185df6

View file

@ -14,7 +14,7 @@
# success, some other number for errors (an empty file is basically the same as # success, some other number for errors (an empty file is basically the same as
# 0). Note that the return codes are text, not raw bytes. # 0). Note that the return codes are text, not raw bytes.
this_repo="$(dirname $(dirname -- "$(readlink -- "${0}")"))" this_repo="$(dirname "$(dirname -- "$(readlink -- "${0}")")")"
help() { help() {
echo \ echo \
@ -68,7 +68,7 @@ run_termux_command() {
return_code=$(adb shell "cat $probe") return_code=$(adb shell "cat $probe")
adb shell "rm $probe" adb shell "rm $probe"
echo "return code: $return_code" echo "return code: $return_code"
return $return_code return "$return_code"
} }
snapshot() { snapshot() {
@ -84,7 +84,7 @@ snapshot() {
return_code=$? return_code=$?
adb pull "$log" . adb pull "$log" .
cat $(basename "$log") cat "$(basename "$log")"
if [[ $return_code -ne 0 ]]; then return $return_code; fi if [[ $return_code -ne 0 ]]; then return $return_code; fi
@ -96,7 +96,7 @@ snapshot() {
run_termux_command "$command" "$probe" run_termux_command "$command" "$probe"
adb pull "$log" . adb pull "$log" .
cat $(basename "$log") cat "$(basename "$log")"
echo "Info about cargo and rust" echo "Info about cargo and rust"
probe='/sdcard/info.probe' probe='/sdcard/info.probe'
@ -117,7 +117,7 @@ snapshot() {
run_termux_command "$command" "$probe" run_termux_command "$command" "$probe"
adb pull "$log" . adb pull "$log" .
cat $(basename "$log") cat "$(basename "$log")"
echo "snapshot complete" echo "snapshot complete"
adb shell input text "exit" && hit_enter && hit_enter adb shell input text "exit" && hit_enter && hit_enter
@ -129,21 +129,21 @@ sync() {
# android doesn't allow symlinks on shared dirs, and adb can't selectively push files # android doesn't allow symlinks on shared dirs, and adb can't selectively push files
symlinks=$(find "$repo" -type l) symlinks=$(find "$repo" -type l)
# dash doesn't support process substitution :( # dash doesn't support process substitution :(
echo $symlinks | sort >symlinks echo "$symlinks" | sort >symlinks
git -C "$repo" diff --name-status | cut -f 2 >modified git -C "$repo" diff --name-status | cut -f 2 >modified
modified_links=$(join symlinks modified) modified_links=$(join symlinks modified)
if [ ! -z "$modified_links" ]; then if [ -n "$modified_links" ]; then
echo "You have modified symlinks. Either stash or commit them, then try again: $modified_links" echo "You have modified symlinks. Either stash or commit them, then try again: $modified_links"
exit 1 exit 1
fi fi
if ! git ls-files --error-unmatch $symlinks >/dev/null; then if ! git ls-files --error-unmatch "$symlinks" >/dev/null; then
echo "You have untracked symlinks. Either remove or commit them, then try again." echo "You have untracked symlinks. Either remove or commit them, then try again."
exit 1 exit 1
fi fi
rm $symlinks rm "$symlinks"
# adb's shell user only has access to shared dirs... # adb's shell user only has access to shared dirs...
adb push "$repo" /sdcard/coreutils adb push "$repo" /sdcard/coreutils
git -C "$repo" checkout $symlinks git -C "$repo" checkout "$symlinks"
# ...but shared dirs can't build, so move it home as termux # ...but shared dirs can't build, so move it home as termux
probe='/sdcard/mv.probe' probe='/sdcard/mv.probe'
command="'cp -r /sdcard/coreutils ~/; touch $probe'" command="'cp -r /sdcard/coreutils ~/; touch $probe'"