I’m writing an interpreter. The interpreter accepts arguments that it itself uses, including a file to interpret. The interpreted program should not see the interpreter arguments when it queries for arguments and should see arguments meant for the interpreted program. But that’s not difficult to do. Instead, I’m interested in styles on how to pass arguments to the program.
For example, the following scenarios could work:
-
interpreter [interpreter args] file [file args] -
interpreter [interpreter args]
Where[interpreter args]include the file and--prog-args n arg1 arg2 ... argn
One could be as clever as he likes with this, but I’m interested in the conventional ways of doing this.
Are you asking about how to parse command line arguments or styles of them?
Look at Perl and Python manpages:
They follow a pattern:
interpreter [interpreter args] file [file args]interpreter -- file [file args]interpreter -e codeThe
--is used to end the interpreter argument list, for example,interpreter -a -b -c -- -dis same asinterpreter -a -b -cFor power users, they will run one-liner scripts, so you should add the
-e CODEflags and also, read code from STDIN when no arguments are persent.