From 4200bb13760ebeff7c4e24e4b987bddd6ee9c645 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Fri, 4 Jun 2021 22:50:05 +0200 Subject: [PATCH] pm3: add option -o/--offline, more convenient than having to call directly the client bin --- pm3 | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/pm3 b/pm3 index 531f80b39..bfdc4d23d 100755 --- a/pm3 +++ b/pm3 @@ -263,6 +263,7 @@ Description: Usage: $SCRIPT [-n ] [] $SCRIPT [--list] [-h|--help] [-hh|--helpclient] + $SCRIPT [-o|--offline] Arguments: @@ -270,7 +271,7 @@ Arguments: -hh/--helpclient proxmark3 client help (the script will forward these options) --list list all detected com ports -n connect device referred to the N:th number on the --list output - + -o/--offline shortcut to use directly the proxmark3 client without guessing ports Samples: ./$SCRIPT -- Auto detect/ select com port in the following order BT, USB/CDC, BT DONGLE @@ -383,18 +384,31 @@ else echo >&2 "[!!] Script ran under unknown name, abort: $SCRIPT" exit 1 fi -if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then - HELP - exit 0 -fi -if [ "$1" == "-hh" ] || [ "$1" == "--helpclient" ]; then - CMD "-h" - exit 0 -fi +# priority to the help options +for ARG; do + if [ "$ARG" == "-h" ] || [ "$ARG" == "--help" ]; then + HELP + exit 0 + fi + if [ "$ARG" == "-hh" ] || [ "$ARG" == "--helpclient" ]; then + CMD "-h" + exit 0 + fi +done + +# if offline, bypass the script and forward all other args +for ARG; do + shift + if [ "$ARG" == "-o" ] || [ "$ARG" == "--offline" ]; then + CMD "$@" + exit $? + fi + set -- "$@" "$ARG" +done # if a port is already provided, let's just run the command as such -for ARG in "$@"; do +for ARG; do if [ "$ARG" == "-p" ]; then CMD "$@" exit $?