Skip to content

Commit

Permalink
Add a proper argument parsing to gef-extras.sh (#872)
Browse files Browse the repository at this point in the history
  • Loading branch information
therealdreg committed Jul 5, 2022
1 parent 819917d commit c530aa5
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions scripts/gef-extras.sh
Expand Up @@ -5,19 +5,32 @@
#
set -e

usage() { echo "Usage: $0 [-b <main|dev>] [-p <path_to_install>]" 1>&2; exit 1; }

branch="main"
if [ "$1" = "dev" ]; then
branch="dev"
echo "set branch to dev"
fi
while getopts ":b:p:" o; do
case "${o}" in
b)
branch=${OPTARG}
;;
p)
path=${OPTARG}
;;
*)
usage
;;
esac
done

if [ $# -ge 1 ]; then
DIR="$(realpath "$1")/gef-extras"
test -d "${DIR}" || exit 1
elif [ -d "${HOME}/.config" ]; then
DIR="${HOME}/.config/gef-extras"
if [ -z "$path" ]; then
if [ -d "${HOME}/.config" ]; then
DIR="${HOME}/.config/gef-extras"
else
DIR="${HOME}/.gef-extras"
fi
else
DIR="${HOME}/.gef-extras"
DIR="$(realpath "$path")/gef-extras"
test -d "${DIR}" || exit 1
fi

git clone --branch ${branch} https://github.com/hugsy/gef-extras.git "${DIR}"
Expand Down

0 comments on commit c530aa5

Please sign in to comment.