From 62420cb44d6e4e7211c8cfa7bd17e636247b1a07 Mon Sep 17 00:00:00 2001 From: c0dist Date: Thu, 2 Jun 2016 12:40:11 +0530 Subject: [PATCH] Pull request fixes issues #1 and Issue #2 * Fixes #1 Exits if file doesn't exist * Fixes #2. Print help if no argument given. The script now checks for number of arguments given by user and prints help, if the number is 0. * Fixes #1. Exits if file does not exist. --- apk2java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/apk2java b/apk2java index 4de0b2b..80f485d 100644 --- a/apk2java +++ b/apk2java @@ -7,7 +7,7 @@ echo "This is a script created by Anant Shrivastava" echo "http://anantshri.info" echo "Designed and Tested on Android Tamer" echo "This script will work on automating the work of extracting the source code out from the apk file" -if [ $1 == "--help" -o $1 == "-help" ] +if [[ $# -eq 0 || $1 == "--help" || $1 == "-help" ]] then echo "" echo "$0 APK_FILE_NAME" @@ -36,6 +36,14 @@ then echo "Only APK's allowed" exit fi + +#Checks if the file exists. +if [ ! -f "$FULL_PTH" ] +then + echo "File not found." + exit +fi + echo "Creating Output Directory" mkdir -p "$SRC_DIR" ls -l @@ -68,4 +76,4 @@ then fi ls -l "$SRC_DIR" cd "$CDIR" -echo "All Done" \ No newline at end of file +echo "All Done"