Getting the original command-line

Michael Davidson md at sco.COM
Thu Dec 20 18:17:19 AEST 1990


In article <1699 at travis.csd.harris.com> brad at 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? 
 [ ... ]
>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.

Sorry, the short answer to your question is "No". The contents of argv[]
*are* the original arguments to the program when it was exec()-ed (unless
the program itself has subsequently changed them, of course). There is no
way that you can get at the original characters that were typed at the
shell command prompt to cause the program to be run (if indeed it was run
from the shell at all ...)

I am also really puzzled by your statement that you want the original
command line "before quotes and slashes are evaluated but after filenames,
aliases and variables have been expanded" - since in all the shells that
I am familiar with backslash and quote characters play a vital role
in determining just exactly how the command line is interpreted and
what filename expansion etc takes place ....

It might help if you explained exactly what you think that you are
trying to achieve.



More information about the Comp.unix.programmer mailing list