Path: utzoo!attcan!uunet!wuarchive!usc!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.programmer Subject: Re: Getting the original command-line Message-ID: <1990Dec10.194645.20725@athena.mit.edu> Date: 10 Dec 90 19:46:45 GMT References: <1699@travis.csd.harris.com> Sender: news@athena.mit.edu (News system) Reply-To: jik@athena.mit.edu (Jonathan I. Kamens) Organization: Massachusetts Institute of Technology Lines: 38 In article <1699@travis.csd.harris.com>, brad@SSD.CSD.HARRIS.COM (Brad Appleton) writes: |> Is there a way in Unix (BSD and/or AT&T) to retrieve the original command-line |> in a C program? If so, what state will it be in? (Will variables and aliases |> be expanded, what about quotes and backslashes, etc ..) No. |> Also - does the shell being used make a difference in how the command-line is |> retrieved? The shell makes all the difference in the world, since the shell is the only thing that knows the command line that the user actually typed. On the other hand, the shell makes no difference at all, since none of the shells that I know of provide any mechanism at all to do what you describe. |> BTW - I really do NOT want argv in this particular case. I want the orignal |> command-line, hopefully before quotes and slashes are evaluated but after |> filenames, aliases, and variables have been expanded. There's a good chance that by the time your program starts up, the shell doesn't even know what command line it used to start it. Even if it does know, that knowledge is completely internal to the shell, and I doubt very much you're going to be able to figure out a feasible way to drag it out of the shell. The closest you could get would be to define a shell script or something that passes its arguments into the program or that writes them to a file for the program to read or something, but since the arguments it gets will have already been interpreted by the shell, all of the evaluations and expansions you mention will already have taken place. Why exactly are you trying to accomplish this? -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710