Skip to content

Commit

Permalink
Merge pull request #700 from BadSugar/ubuntu_fix_gef_sh
Browse files Browse the repository at this point in the history
gef.sh is now works on Ubuntu 21.04 (Hirsute Hippo) #699
  • Loading branch information
hugsy committed Aug 21, 2021
2 parents 5a9b2a2 + 05520e2 commit e152a34
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions scripts/gef.sh
Expand Up @@ -3,16 +3,39 @@
set -e

branch="master"
test "$1" == "dev" && branch="dev"
if [ "$1" = "dev" ]; then
branch="dev"
echo "set branch to dev"
fi

# check dependencies
if [ `which curl` ]; then
curl_found=1
elif [ `which wget` ]; then
wget_found=1
else
echo "Please install cURL or wget and run again"
exit 1
fi

# Backup gdbinit if any
test -f "${HOME}/.gdbinit" && mv "${HOME}/.gdbinit" "${HOME}/.gdbinit.old"
if [ -f "${HOME}/.gdbinit" ]; then
mv "${HOME}/.gdbinit" "${HOME}/.gdbinit.old"
fi

if [ $wget_found -eq 1 ]; then
# Get the hash of the commit
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 '"')

# Get the hash of the commit
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
wget -q "https://github.com/hugsy/gef/raw/${branch}/gef.py" -O "${HOME}/.gef-${ref}.py"
elif [ $curl_found -eq 1 ]; then
# Get the hash of the commit
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
curl --silent --location --output "${HOME}/.gef-${ref}.py" "https://github.com/hugsy/gef/raw/${branch}/gef.py"
# Download the file
curl --silent --location --output "${HOME}/.gef-${ref}.py" "https://github.com/hugsy/gef/raw/${branch}/gef.py"
fi

# Create the new gdbinit
echo "source ~/.gef-${ref}.py" > ~/.gdbinit
Expand Down

0 comments on commit e152a34

Please sign in to comment.