Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!wuarchive!ukma!psuvax1!hsdndev!cmcl2!lanl!cochiti.lanl.gov!jlg From: jlg@cochiti.lanl.gov (Jim Giles) Newsgroups: comp.lang.fortran Subject: Re: Command line arguements? Message-ID: <24713@lanl.gov> Date: 30 May 91 19:16:24 GMT References: <24632@lanl.gov> <1991May30.174626.12965@cs.dal.ca> Sender: news@lanl.gov Organization: Los Alamos National Laboratory Lines: 40 In article <1991May30.174626.12965@cs.dal.ca>, silvert@cs.dal.ca (Bill Silvert) writes: |> In article <24632@lanl.gov> jlg@cochiti.lanl.gov (Jim Giles) writes: |> >[...] |> >Yeah. I've always wanted to be able to do this on UNIX (with _any_ |> >language). Unfortunately, the shell trashes the command line before |> >I can have a look at it. I can turn that unsavory behaviour off - |> >which is fine for me, but I can't be sure all the users of my software |> >will turn it off. So, I have to do without a command line and deal |> >with the junk the shell gives me instead. |> |> Can you clarify this? I've been using getarg() and iargc() for years on |> all kinds of systems, and I distribute software that uses these calls. |> Could you explain under what circumstances they don't work? As I said above, the _shell_ processes the command line before I get to look at it. So, getarg() and iargc() don't give me the arguments that the user typed, they give me the _processed_ arguments. This means that my command line syntax has to avoid quotes, backslashes, wildcard characters, and probably a few other things. If the shell passed the _unprocessed_ command line _in_addition_ to the parsed argument list (either as another argument to main() or as an environment variable) then I could design code which used any command line syntax I wanted. In particular, I could apply the same wildcard and quoting conventions to alternative search spaces - not just to local file names. For example, I could have a phonebook program that listed phone numbers for people specified as: cochiti => phone s*m S*de Which would find (say) Sam Spade and print his number. It would also find Slim Shade, etc.. You get the picture. At present, the only ways to do this are to require the user to quote the patterns to get them past the shell or to make the utility interactive: ignore the command line and ask for the name interactively. Neither one of these is really what I want. Quoting intuitively means _not_ to expand wildcards, that's what I would want it to mean in a utility. Going interactive is less convenient (extra work to call from within a script, for example). J. Giles