Add support to run commands over shell and return output

This makes it possible to do:
 androdeb shell ls -la

Signed-off-by: Joel Fernandes <joel@joelfernandes.org>
diff --git a/addons/run-command b/addons/run-command
index c58a002..01c182c 100755
--- a/addons/run-command
+++ b/addons/run-command
@@ -3,6 +3,6 @@
 cd $spath
 
 # Directly execute a command within the chroot of an Android device
-CMD=$1
+CMD="$*"
 
 chroot debian /bin/bash -i -c "$CMD"
diff --git a/androdeb b/androdeb
index f4e613d..eb08876 100755
--- a/androdeb
+++ b/androdeb
@@ -27,6 +27,17 @@
 # Parse command line parameters
 if [ $# -lt 1 ]; then usage; fi; POSITIONAL=()
 while [[ $# -gt 0 ]]; do key="$1";
+
+# If its shell mode, any future args become shell's args
+if [ "x$ASHELL" == "x1" ]; then
+	if [ -z "$SHELL_ARGS" ]; then
+		SHELL_ARGS=$key
+	else
+		SHELL_ARGS="$SHELL_ARGS $key"
+	fi
+	shift || true; continue
+fi
+
 case $key in
     prepare) PREPARE=1;  shift || true;    ;;
     shell) ASHELL=1;     shift || true;     ;;
@@ -123,7 +134,16 @@
 	   die 2 "Device doesn't have an androdeb environment, run \"./androdeb prepare\" first";
 	fi; set -e
 
-	$ADB shell -t /data/androdeb/run
+	if [ ! -z ${SHELL_ARGS+x} ]; then
+		# Explanation of quotes:
+		# Outer quote is so that androdeb's bash passes the SHELL_ARGS as a single
+		# argument to $ADB shell. Inner quotes is so that run-command can receive all
+		# the args even though they may be separated by spaces. \m/
+		$ADB shell -t /data/androdeb/run-command "\"$SHELL_ARGS\""
+	else
+		$ADB shell -t /data/androdeb/run
+	fi
+
 	exit 0
 fi