home *** CD-ROM | disk | FTP | other *** search
- From: darcy@druid.uucp (D'Arcy J.M. Cain)
-
- In article <742@longway.TIC.COM> std-unix@uunet.uu.net writes:
- >From: lezz@codex.uucp (Leslie Giles)
- >darcy@druid.uucp (D'Arcy J.M. Cain) writes:
- >> ... You can
- >>also initialise the argument list more than once supporting things such
- >>as environment default command lines, arguments from files etc mixed
- >>with arguments from the command line. I just posted it recently to
- >>alt.sources and I'm interested in getting some feedback on it.
- >
- >It is also possible to restart getopt() by setting various variables.
- >I did this in some code to support defaults, as mentioned above. If anybody
- >wants to know how to do this then you can mail me (I don't have the code in
- >front of me at the moment - it'd take time to find it) at...
- >
- I guess I wasn't clear in that paragraph. The posting goes into great detail
- about this but the main point is not that you can restart your argument
- processing but that another set of arguments can be stuffed into the ones
- you already have. It allows for something like the following: Say you
- have a program called foo which takes options a & b with no arguments and
- f with an argument "on" or "off". Perhaps the user normally wants this flag
- off but wants to override that default this time. Also the a flag is always
- used. The .profile has the following line:
-
- foo="-a -f off"
-
- Assume also that there is a file called bar with the following line:
-
- -b
-
- then he calls the program like this:
-
- foo -f on -@ bar file1 -f off file2
-
- Assuming that the program is set up correctly then the effective command
- is
-
- foo -a -f off -f on -b file1 -f off file2
-
- Which should process file1 with the flag turned on and file2 with the flag
- turned off. As you can see, The environment variable is stuffed into the
- command line between the program name and the first argument and the contents
- of the file bar is inserted in the line where the file name appears. While
- it may be possible to do something like that with getopt I imagine it would
- not be as simple as with my interface.
-
- --
- D'Arcy J.M. Cain (darcy@druid) | Government:
- D'Arcy Cain Consulting | Organized crime with an attitude
- West Hill, Ontario, Canada |
- (416) 281-6094 |
-
- Note to moderator: I think this is the wrong group to discuss but I can't
- decide the proper one. Please feel free to add a followup-to line if you
- wish.
-
- [ I don't know a better place for it, either. -mod ]
-
- Volume-Number: Volume 20, Number 73
-
-