Arguments via environment variables in delink.sh

It was really annoying having to type all that in every time.
This commit is contained in:
KeybadeBlox 2026-02-12 16:16:07 -05:00
parent 13048fef71
commit 78127e64ef

View file

@ -3,11 +3,21 @@
# objects.csv and a Ghidra project via boricj's delinker extension
main() {
if [ $# -ne 3 ]; then usage; fi
ghidra_path=$1
project_path=$2
project_name=$3
if \
[ $# -eq 0 ] &&\
[ -n "${GHIDRA_HOME-}" ] &&\
[ -n "${JSRFDECOMP_PROJECTPATH-}" ] &&\
[ -n "${JSRFDECOMP_PROJECTNAME-}" ]
then
ghidra_path=$GHIDRA_HOME
project_path=$JSRFDECOMP_PROJECTPATH
project_name=$JSRFDECOMP_PROJECTNAME
elif [ $# -eq 3 ]; then
ghidra_path=$1
project_path=$2
project_name=$3
else usage
fi
printf '=== Delinking object files into ../decompile/target/ ===\n'
@ -39,6 +49,9 @@ usage() {
' GHIDRA_PATH is the path to your Ghidra installation'\
' PROJECT_PATH is the path to your JSRF Ghidra project'\
' PROJECT_NAME is the name of your JSRF Ghidra project'\
'Alternatively, the environment variables $GHIDRA_HOME, $JSRFDECOMP_PROJECTPATH,'\
'and $JSRFDECOMP_PROJECTNAME can be set, and the script can be called with no'\
'arguments.'\
''\
'Populates the target/ directory with delinked object files using the address'\
'ranges given in objects.csv.' >& 2