-
Notifications
You must be signed in to change notification settings - Fork 13
Support passing arguments to scripts from command line #13
Copy link
Copy link
Open
Labels
Description
The immediate idea is to use $1, $2, etc. to refer to first, second, etc. command line argument.
Another possibility, maybe more in line with how dwgrep generally operates, is to have a word like argv that yields individual command line arguments. One could say things like argv (pos == 0) to get a particular one. That's less handy and I'm not sure passing arbitrary command line lists is useful. In the end, both can be present.
- These would have to be passed in not only from command line, but also from the C and C++ wrappers. While C and C++ wrappers could pass in arbitrary value subclasses, only strings would come from the command line.
- Systemtap has
@1,@2, etc. for literals.$1,$2, etc. are pasted verbatim (macro-expanded so to speak) and lexed and parsed. This would allow the "17" be passed in as 17, "DW_AT_name" as DW_AT_name, etc. But we use@for attribute access, and we might want to use@1for access to location expression values (where currently you have to awkwardly typevalue (pos == 0)), macro arguments or possibly other things like that. Maybe we just need a wordeval. - These could act like variables defined in outermost scope, which would simplify referencing them. Type inference (when/if it's done) would have to be done after these arguments are provided.
- Command line interface would have to be changed so that it's clear where the arguments come from. We could use
--argslike GDB does. We shouldn't break the use case where one just dumps a bunch of files todwgrepthrough to command line, such asdwgrep 'my query' $(find my files). That shouldn't translate to a bunch of script command line arguments.
Reactions are currently unavailable