Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make shebang lines portable #814

Merged
merged 4 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions scripts/gef-extras.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

if [ $# -ge 1 ]; then
DIR="$(realpath $1)/gef-extras"
test -d ${DIR} || exit 1
elif [ -d ${HOME}/.config ]; then
DIR="$(realpath "$1")/gef-extras"
theguy147 marked this conversation as resolved.
Show resolved Hide resolved
test -d "${DIR}" || exit 1
elif [ -d "${HOME}/.config" ]; then
DIR="${HOME}/.config/gef-extras"
else
DIR="${HOME}/.gef-extras"
fi

git clone https://github.com/hugsy/gef-extras.git ${DIR}
git clone https://github.com/hugsy/gef-extras.git "${DIR}"
gdb -q -ex "gef config gef.extra_plugins_dir '${DIR}/scripts'" \
-ex "gef config pcustom.struct_path '${DIR}/structs'" \
-ex "gef config syscall-args.path '${DIR}/syscall-tables'" \
Expand Down
6 changes: 3 additions & 3 deletions scripts/gef.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand All @@ -12,9 +12,9 @@ curl_found=0
wget_found=0

# check dependencies
if [ `which curl` ]; then
if [ "$(which curl)" ]; then
curl_found=1
elif [ `which wget` ]; then
elif [ "$(which wget)" ]; then
wget_found=1
else
echo "Please install cURL or wget and run again"
Expand Down
10 changes: 5 additions & 5 deletions scripts/generate-api-docs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

Expand All @@ -16,7 +16,7 @@ check()

clean_doc()
{
rm -fr -- ${output_path}/*.md
rm -fr -- "${output_path}/*.md"
}


Expand All @@ -33,13 +33,13 @@ generate_doc()
fixup_doc()
{
# rename
mv ${output_path}/__main__.md ${full_doc_path}
mv "${output_path}/__main__.md" "${full_doc_path}"

# replace the title
sed -i 's?# <kbd>module</kbd> `__main__`?# <kbd>module</kbd> `GEF`?' ${full_doc_path}
sed -i 's?# <kbd>module</kbd> `__main__`?# <kbd>module</kbd> `GEF`?' "${full_doc_path}"

# fix the hrefs
sed -i -ze 's!<a href="\([^"]*\)[^`]*`\([^`]*\)`!<a href="https://cs.github.com/hugsy/gef?q=\2"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>\n\n## <kbd>function</kbd> `\2`!g' ${full_doc_path}
sed -i -ze 's!<a href="\([^"]*\)[^`]*`\([^`]*\)`!<a href="https://cs.github.com/hugsy/gef?q=\2"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>\n\n## <kbd>function</kbd> `\2`!g' "${full_doc_path}"
}

check
Expand Down
32 changes: 16 additions & 16 deletions tests/perf/context_times.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

# Bail out early on an unexpected error
set -e
Expand All @@ -17,13 +17,13 @@ get_context_time() {
}

log_this_revision() {
rev=`git log -1 --pretty="format:%h"`
printf $rev
title=`git log -1 --pretty="format:%s"`
printf ",\"$title\""
for i in `seq 1 5`; do
rv=`$1`
printf ",$rv"
rev=$(git log -1 --pretty="format:%h")
printf "%s" "$rev"
title=$(git log -1 --pretty="format:%s")
printf ",\"%s\"" "$title"
for _ in $(seq 1 5); do
theguy147 marked this conversation as resolved.
Show resolved Hide resolved
rv=$($1)
printf ",%s" "$rv"
done
printf "\n"
}
Expand All @@ -39,7 +39,7 @@ clear_stats() {
}

get_current_branch_or_commit() {
b=`git branch | grep '\* '`
b=$(git branch | grep '\* ')
case "$b" in
*HEAD*)
echo "$b" | tr -d ')' | cut -f 5 -d ' ';;
Expand All @@ -53,23 +53,23 @@ run_on_git_revisions() {
end_ref=$2
test_command=$3

orig_rev=`get_current_branch_or_commit`
revs=`git rev-list --reverse ${start_ref}..${end_ref}`
orig_rev=$(get_current_branch_or_commit)
revs=$(git rev-list --reverse "${start_ref}".."${end_ref}")

for rev in $revs; do
echo "Checking out: $(git log --oneline -1 $rev)"
git checkout --quiet $rev
log_command $test_command
echo "Checking out: $(git log --oneline -1 "$rev")"
git checkout --quiet "$rev"
log_command "$test_command"
git reset --hard --quiet
done

echo "Restoring original commit/branch: $orig_rev"
git checkout --quiet $orig_rev
git checkout --quiet "$orig_rev"
}

if [ $# == "2" ]; then
clear_stats
run_on_git_revisions $1 $2 "time_gef_context"
run_on_git_revisions "$1" "$2" "time_gef_context"
else
echo "usage: $0 first_commit last_commit"
fi
2 changes: 1 addition & 1 deletion tests/run-remote.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Bash script to automate running the tests running from any remote machine
# (assumes GDB+Python3, requires sudo NOPASSWD)
Expand Down