Skip to content

Commit

Permalink
make a clear deference between adb shell fail and adb error
Browse files Browse the repository at this point in the history
  • Loading branch information
matan-h committed Apr 15, 2024
1 parent d0f83f2 commit d73b504
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 5 additions & 2 deletions adb-shell.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
$STARTUP = "/sdcard/.adb/startup.sh"
adb shell "[ -f $STARTUP ]" ;
if (-not $?){ # $?: command success status (true if the last command was successful)
adb shell "[ -f $STARTUP ] || exit 6" ;
if ($LastExitCode -eq 6){ # $?: command success status (true if the last command was successful)
Write-Output "file not found, push with adb"
adb push "$PSScriptRoot/startup.sh" $STARTUP
}
if ($LastExitCode -eq 1){ # adb error
exit 1
}
adb shell -t "HOME='/sdcard' ENV='$STARTUP' sh -i -o emacs -o vi-tabcomplete"
8 changes: 7 additions & 1 deletion adb-shell.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#! /bin/bash
STARTUP=/sdcard/.adb/startup.sh
if ! adb shell "[ -f $STARTUP ]" ; then
adb shell "[ -f $STARTUP ] || exit 6";
last_exit_status=$?

if [ $last_exit_status -eq 6 ] ; then
echo "file not found, push with adb"
adb push "$(dirname "$0")/startup.sh" $STARTUP

elif [ $last_exit_status -eq 1 ]; then # adb error
exit 1
fi
# for most shells, '-o emacs -o vi-tabcomplete' is the default, but for some it isn't.
adb shell -t "HOME='/sdcard' ENV='$STARTUP' sh -i -o emacs -o vi-tabcomplete"

0 comments on commit d73b504

Please sign in to comment.