Closed blbelew closed 3 days ago
We took a different approach to this solution. Instead of introducing --
, we simply treat any argument that we don't support as an argument to the user scripts. This means your scripts won't be able to accept things like -import
and -prescript
, but any args of the form --arg
should now behave like you want them too.
Top-level request: support "--" as an end-of-options indicator in the analyzeHeadless helper script so that arguments starting with "-" can be passed to user scripts.
More context:
The analyzeHeadless helper script has the ability to launch a specified user script in headless mode. All arguments at the end of the analyzeHeadless invocation get passed to the script. It is common practice for Python scripts (especially those using argparse) to take options with leading dashes. However, any option starting with "-" is interpreted as an argument to analyzeHeadless itself.
It is a common convention in many scripting environments (bash, python argparse, other GNU tools like grep) to use an empty "--" to indicate the end of options so that further arguments can start with dashes and won't be interpreted as option flags. For instance, to remove a file that starts with a dash with rm, you would do
rm -- -weird-file
, as otherwise-weird file
would be interpreted as a flag to rm, causing an error. See https://unix.stackexchange.com/questions/11376/what-does-double-dash-double-hyphen-mean and https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02 guideline 10 for more context.analyzeHeadless should support this convention, so that e.g.
analyzeHeadless ghidra://ghidra-server.com/project/path -process binary.bin -noanalysis -postscript some_user_script.py -- --arg1-for-script
would pass--arg1-for-script
tosome_user_script.py
.