diff --git a/Ghidra/RuntimeScripts/Linux/ghidraRun b/Ghidra/RuntimeScripts/Linux/ghidraRun index 734e28b2d3..e97e68ce2d 100755 --- a/Ghidra/RuntimeScripts/Linux/ghidraRun +++ b/Ghidra/RuntimeScripts/Linux/ghidraRun @@ -23,6 +23,6 @@ VMARG_LIST="${GHIDRA_JAVA_OPTIONS} ${GHIDRA_GUI_JAVA_OPTIONS} " # contains the link you are calling (which is the best we can do on macOS), and the "echo" is the # fallback, which doesn't attempt to do anything with links. SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" -SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)" +SCRIPT_DIR="$(dirname -- "$SCRIPT_FILE")" # Launch Ghidra "${SCRIPT_DIR}"/support/launch.sh bg jdk Ghidra "${GHIDRA_GUI_MAXMEM}" "${VMARG_LIST}" ghidra.GhidraRun "$@" diff --git a/Ghidra/RuntimeScripts/Linux/server/ghidraSvr b/Ghidra/RuntimeScripts/Linux/server/ghidraSvr index 88771a237b..5839ebd9e3 100755 --- a/Ghidra/RuntimeScripts/Linux/server/ghidraSvr +++ b/Ghidra/RuntimeScripts/Linux/server/ghidraSvr @@ -75,7 +75,7 @@ WRAPPER_TMPDIR="${TMPDIR:-/tmp}" # contains the link you are calling (which is the best we can do on macOS), and the "echo" is the # fallback, which doesn't attempt to do anything with links. SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" -SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)" +SCRIPT_DIR="$(dirname -- "$SCRIPT_FILE")" # Ensure Ghidra path doesn't contain illegal characters if [[ "${SCRIPT_DIR}" = *"!"* ]]; then echo "Ghidra path cannot contain a \"!\" character." diff --git a/Ghidra/RuntimeScripts/Linux/server/svrAdmin b/Ghidra/RuntimeScripts/Linux/server/svrAdmin index ee9f35bb4c..e7e74ef585 100755 --- a/Ghidra/RuntimeScripts/Linux/server/svrAdmin +++ b/Ghidra/RuntimeScripts/Linux/server/svrAdmin @@ -31,7 +31,7 @@ MAXMEM=128M # contains the link you are calling (which is the best we can do on macOS), and the "echo" is the # fallback, which doesn't attempt to do anything with links. SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" -SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)" +SCRIPT_DIR="$(dirname -- "$SCRIPT_FILE")" if [ -d "${SCRIPT_DIR}/../Ghidra" ]; then # Production Environment CONFIG="${SCRIPT_DIR}/server.conf" diff --git a/Ghidra/RuntimeScripts/Linux/support/GhidraGo/ghidraGo b/Ghidra/RuntimeScripts/Linux/support/GhidraGo/ghidraGo index 47f5f2c6a4..0834a72aef 100755 --- a/Ghidra/RuntimeScripts/Linux/support/GhidraGo/ghidraGo +++ b/Ghidra/RuntimeScripts/Linux/support/GhidraGo/ghidraGo @@ -10,6 +10,6 @@ LAUNCH_MODE=fg # contains the link you are calling (which is the best we can do on macOS), and the "echo" is the # fallback, which doesn't attempt to do anything with links. SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" -SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)" +SCRIPT_DIR="$(dirname -- "$SCRIPT_FILE")" # Launch Filesystem Conversion "${SCRIPT_DIR}"/../launch.sh $LAUNCH_MODE jdk GhidraGo "" "" ghidra.GhidraGo "$@" diff --git a/Ghidra/RuntimeScripts/Linux/support/analyzeHeadless b/Ghidra/RuntimeScripts/Linux/support/analyzeHeadless index cf2c74c264..90209f7887 100755 --- a/Ghidra/RuntimeScripts/Linux/support/analyzeHeadless +++ b/Ghidra/RuntimeScripts/Linux/support/analyzeHeadless @@ -36,7 +36,7 @@ DEBUG_ADDRESS=127.0.0.1:13002 # contains the link you are calling (which is the best we can do on macOS), and the "echo" is the # fallback, which doesn't attempt to do anything with links. SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" -SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)" +SCRIPT_DIR="$(dirname -- "$SCRIPT_FILE")" # Launch HeadlessAnalyzer. # DEBUG_ADDRESS set via environment for launch.sh DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra-Headless "${GHIDRA_HEADLESS_MAXMEM}" "${VMARG_LIST}" ghidra.app.util.headless.AnalyzeHeadless "$@" diff --git a/Ghidra/RuntimeScripts/Linux/support/bsim b/Ghidra/RuntimeScripts/Linux/support/bsim index 638d026797..b508550ed4 100755 --- a/Ghidra/RuntimeScripts/Linux/support/bsim +++ b/Ghidra/RuntimeScripts/Linux/support/bsim @@ -27,5 +27,5 @@ LAUNCH_MODE=fg # contains the link you are calling (which is the best we can do on macOS), and the "echo" is the # fallback, which doesn't attempt to do anything with links. SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" -SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)" +SCRIPT_DIR="$(dirname -- "$SCRIPT_FILE")" ${SCRIPT_DIR}/launch.sh $LAUNCH_MODE jdk "BSim" "${GHIDRA_BSIM_MAXMEM}" "${VMARG_LIST}" ghidra.features.bsim.query.ingest.BSimLaunchable "$@" diff --git a/Ghidra/RuntimeScripts/Linux/support/bsim_ctl b/Ghidra/RuntimeScripts/Linux/support/bsim_ctl index d5f10a91bd..3738689a19 100755 --- a/Ghidra/RuntimeScripts/Linux/support/bsim_ctl +++ b/Ghidra/RuntimeScripts/Linux/support/bsim_ctl @@ -15,5 +15,5 @@ VMARG_LIST="-Djava.awt.headless=true " # contains the link you are calling (which is the best we can do on macOS), and the "echo" is the # fallback, which doesn't attempt to do anything with links. SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" -SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)" +SCRIPT_DIR="$(dirname -- "$SCRIPT_FILE")" ${SCRIPT_DIR}/launch.sh $LAUNCH_MODE jdk "BSimControl" $MAXMEM "${VMARG_LIST}" ghidra.features.bsim.query.BSimControlLaunchable "$@" diff --git a/Ghidra/RuntimeScripts/Linux/support/buildGhidraJar b/Ghidra/RuntimeScripts/Linux/support/buildGhidraJar index 7d8314fdf2..90262fc1e3 100755 --- a/Ghidra/RuntimeScripts/Linux/support/buildGhidraJar +++ b/Ghidra/RuntimeScripts/Linux/support/buildGhidraJar @@ -16,7 +16,7 @@ LAUNCH_MODE=fg # contains the link you are calling (which is the best we can do on macOS), and the "echo" is the # fallback, which doesn't attempt to do anything with links. SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" -SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)" +SCRIPT_DIR="$(dirname -- "$SCRIPT_FILE")" GHIDRA_ROOT_DIR="${SCRIPT_DIR}"/../Ghidra if [ ! -d "${GHIDRA_ROOT_DIR}" ]; then echo "This script does not support development mode use" diff --git a/Ghidra/RuntimeScripts/Linux/support/convertStorage b/Ghidra/RuntimeScripts/Linux/support/convertStorage index 72722ee1a2..d4d0f07b76 100755 --- a/Ghidra/RuntimeScripts/Linux/support/convertStorage +++ b/Ghidra/RuntimeScripts/Linux/support/convertStorage @@ -13,6 +13,6 @@ MAXMEM=128M # contains the link you are calling (which is the best we can do on macOS), and the "echo" is the # fallback, which doesn't attempt to do anything with links. SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" -SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)" +SCRIPT_DIR="$(dirname -- "$SCRIPT_FILE")" # Launch Filesystem Conversion "${SCRIPT_DIR}"/launch.sh fg jdk ConvertStorage "${MAXMEM}" "" ghidra.framework.data.ConvertFileSystem "$@" diff --git a/Ghidra/RuntimeScripts/Linux/support/gdbGADPServerRun b/Ghidra/RuntimeScripts/Linux/support/gdbGADPServerRun index 7b3baa0556..c6305e3a4d 100755 --- a/Ghidra/RuntimeScripts/Linux/support/gdbGADPServerRun +++ b/Ghidra/RuntimeScripts/Linux/support/gdbGADPServerRun @@ -13,6 +13,6 @@ # contains the link you are calling (which is the best we can do on macOS), and the "echo" is the # fallback, which doesn't attempt to do anything with links. SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" -SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)" +SCRIPT_DIR="$(dirname -- "$SCRIPT_FILE")" # Launch Ghidra "${SCRIPT_DIR}"/launch.sh fg jdk GdbAgent "${MAXMEM}" "" agent.gdb.gadp.GdbGadpServerLaunchShim $@ diff --git a/Ghidra/RuntimeScripts/Linux/support/ghidraClean b/Ghidra/RuntimeScripts/Linux/support/ghidraClean index be89ab2fda..0303cfcd15 100755 --- a/Ghidra/RuntimeScripts/Linux/support/ghidraClean +++ b/Ghidra/RuntimeScripts/Linux/support/ghidraClean @@ -16,5 +16,5 @@ VMARG_LIST="-Djava.awt.headless=true " # contains the link you are calling (which is the best we can do on macOS), and the "echo" is the # fallback, which doesn't attempt to do anything with links. SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" -SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)" +SCRIPT_DIR="$(dirname -- "$SCRIPT_FILE")" "${SCRIPT_DIR}"/launch.sh fg jre Ghidra-Clean "$MAXMEM" "$VMARG_LIST" utility.application.AppCleaner Ghidra diff --git a/Ghidra/RuntimeScripts/Linux/support/ghidraDebug b/Ghidra/RuntimeScripts/Linux/support/ghidraDebug index bd1347745b..baf249c814 100755 --- a/Ghidra/RuntimeScripts/Linux/support/ghidraDebug +++ b/Ghidra/RuntimeScripts/Linux/support/ghidraDebug @@ -30,7 +30,7 @@ DEBUG_ADDRESS=127.0.0.1:18001 # contains the link you are calling (which is the best we can do on macOS), and the "echo" is the # fallback, which doesn't attempt to do anything with links. SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" -SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)" +SCRIPT_DIR="$(dirname -- "$SCRIPT_FILE")" # Launch Ghidra in debug mode # DEBUG_ADDRESS set via environment for launch.sh DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra "${GHIDRA_GUI_MAXMEM}" "${VMARG_LIST}" ghidra.GhidraRun "$@" diff --git a/Ghidra/RuntimeScripts/Linux/support/jshellRun b/Ghidra/RuntimeScripts/Linux/support/jshellRun index 69850ceac4..8ae350f29a 100755 --- a/Ghidra/RuntimeScripts/Linux/support/jshellRun +++ b/Ghidra/RuntimeScripts/Linux/support/jshellRun @@ -23,6 +23,6 @@ VMARG_LIST="${GHIDRA_JAVA_OPTIONS} ${GHIDRA_JSHELL_JAVA_OPTIONS} " # contains the link you are calling (which is the best we can do on macOS), and the "echo" is the # fallback, which doesn't attempt to do anything with links. SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" -SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)" +SCRIPT_DIR="$(dirname -- "$SCRIPT_FILE")" # Launch Ghidra "${SCRIPT_DIR}"/launch.sh fg jdk Ghidra-JShell "${GHIDRA_JSHELL_MAXMEM}" "${VMARG_LIST}" ghidra.JShellRun "$@" diff --git a/Ghidra/RuntimeScripts/Linux/support/jythonRun b/Ghidra/RuntimeScripts/Linux/support/jythonRun index f211460b47..5392a6ee54 100755 --- a/Ghidra/RuntimeScripts/Linux/support/jythonRun +++ b/Ghidra/RuntimeScripts/Linux/support/jythonRun @@ -35,7 +35,7 @@ DEBUG_ADDRESS=127.0.0.1:13002 # contains the link you are calling (which is the best we can do on macOS), and the "echo" is the # fallback, which doesn't attempt to do anything with links. SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" -SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)" +SCRIPT_DIR="$(dirname -- "$SCRIPT_FILE")" # Launch Ghidra Jython # DEBUG_ADDRESS set via environment for launch.sh DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk "Ghidra-Jython" "${GHIDRA_JYTHON_MAXMEM}" "${VMARG_LIST}" ghidra.jython.JythonRun "$@" diff --git a/Ghidra/RuntimeScripts/Linux/support/launch.sh b/Ghidra/RuntimeScripts/Linux/support/launch.sh index ac4b73a78c..c4a90c291a 100755 --- a/Ghidra/RuntimeScripts/Linux/support/launch.sh +++ b/Ghidra/RuntimeScripts/Linux/support/launch.sh @@ -93,7 +93,7 @@ if [[ ${INDEX} -lt 6 ]]; then fi # Sets SUPPORT_DIR to the directory that contains this file (launch.sh) -SUPPORT_DIR="$(cd "$(dirname "$0")" && pwd)" +SUPPORT_DIR="$(dirname -- "$0")" # Ensure Ghidra path doesn't contain illegal characters if [[ "${SUPPORT_DIR}" = *"!"* ]]; then echo "Ghidra path cannot contain a \"!\" character." diff --git a/Ghidra/RuntimeScripts/Linux/support/pyghidraRun b/Ghidra/RuntimeScripts/Linux/support/pyghidraRun index 03cd1a2f7e..ab3ff36035 100755 --- a/Ghidra/RuntimeScripts/Linux/support/pyghidraRun +++ b/Ghidra/RuntimeScripts/Linux/support/pyghidraRun @@ -9,7 +9,7 @@ # contains the link you are calling (which is the best we can do on macOS), and the "echo" is the # fallback, which doesn't attempt to do anything with links. SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" -SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)" +SCRIPT_DIR="$(dirname -- "$SCRIPT_FILE")" # Since JPype doesn't seem to pick up JDK_JAVA_OPTIONS automatically, include it ourselves VMARG_LIST="${JDK_JAVA_OPTIONS}" diff --git a/Ghidra/RuntimeScripts/Linux/support/sleigh b/Ghidra/RuntimeScripts/Linux/support/sleigh index 2974c38d79..8aa956ae25 100755 --- a/Ghidra/RuntimeScripts/Linux/support/sleigh +++ b/Ghidra/RuntimeScripts/Linux/support/sleigh @@ -15,5 +15,5 @@ VMARG_LIST="-Djava.awt.headless=true " # contains the link you are calling (which is the best we can do on macOS), and the "echo" is the # fallback, which doesn't attempt to do anything with links. SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")" -SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)" +SCRIPT_DIR="$(dirname -- "$SCRIPT_FILE")" "${SCRIPT_DIR}"/launch.sh fg jdk Sleigh "$MAXMEM" "${VMARG_LIST}" ghidra.pcodeCPort.slgh_compile.SleighCompileLauncher "$@"