diff --git a/scripts/gef-extras.sh b/scripts/gef-extras.sh index 7a8d3bc4a..5cfdc278d 100755 --- a/scripts/gef-extras.sh +++ b/scripts/gef-extras.sh @@ -5,9 +5,11 @@ # set -e -usage() { echo "Usage: $0 [-b ] [-p ]" 1>&2; exit 1; } +usage() { echo "Usage: $0 [-b ] [-p ]" 1>&2; exit 1; } -branch="main" +latest_tag=$(curl -s "https://api.github.com/repos/hugsy/gef/tags" | grep "name" | head -1 | sed -e 's/"name": "\([^"]*\)",/\1/' -e 's/\s*//') + +branch=${latest_tag} while getopts ":b:p:" o; do case "${o}" in b) diff --git a/scripts/gef.sh b/scripts/gef.sh index bc5b32ec6..de7c648aa 100755 --- a/scripts/gef.sh +++ b/scripts/gef.sh @@ -2,7 +2,6 @@ set -e -branch="main" curl_found=0 wget_found=0 @@ -22,13 +21,19 @@ if [ -f "${HOME}/.gdbinit" ]; then fi if [ $wget_found -eq 1 ]; then + latest_tag=$(wget -q -O- "https://api.github.com/repos/hugsy/gef/tags" | grep "name" | head -1 | sed -e 's/"name": "\([^"]*\)",/\1/' -e 's/\s*//') + # Get the hash of the commit + branch="${latest_tag}" ref=$(wget -q -O- https://api.github.com/repos/hugsy/gef/git/ref/heads/${branch} | grep '"sha"' | tr -s ' ' | cut -d ' ' -f 3 | tr -d "," | tr -d '"') # Download the file wget -q "https://github.com/hugsy/gef/raw/${branch}/gef.py" -O "${HOME}/.gef-${ref}.py" elif [ $curl_found -eq 1 ]; then + latest_tag=$(curl -s "https://api.github.com/repos/hugsy/gef/tags" | grep "name" | head -1 | sed -e 's/"name": "\([^"]*\)",/\1/' -e 's/\s*//') + # Get the hash of the commit + branch="${latest_tag}" ref=$(curl --silent https://api.github.com/repos/hugsy/gef/git/ref/heads/${branch} | grep '"sha"' | tr -s ' ' | cut -d ' ' -f 3 | tr -d "," | tr -d '"') # Download the file