I propose that we add, in a standard way, access to the command line used to
initiate a program. The command line should have already had aliasing and
environment variable substitution done, but NOT have globbing or dequoting
done.
Here's why:
I've run into multiple problems when trying to port DOS/Win programs to UNIX
programs. There is just not enough flexibility in the UNIX systems about
command line parsing. The program never gets to interpret the command line
in a more complicated way if it's needed. UNIX hides all command line
processing before the program even gets to see the original command line.
Current problems:
1) Unable to differentiatiate "*.c" from \*.c , which is not really a
problems as both should be the same thing given current interpretations.
However, you can't differentiate -x from "-x". This causes tons of email
asking how to delete a file with a leading dash (-).
2) Null arguments for options can be lost: -foo: "" is different
from -foo:"" which loses the trailing quotes and therefore it's null
argument.
3) Target wildcards are not possible using normal command line syntax as it
stands now, i.e. 'cp *.c *.c.o' does not do what you intuitively expect. DOS
systems have had this for a few years (refer to #5).
4) DOS-style response files are difficult to implement because there is no
5) It would allow easier porting of applications between DOS/Win and UNIX
systems.
I propose that all standard shells store the command line after redirection,
subshell execution (i.e. echo `date`), aliasing, and environment variable
substitution (but BEFORE dequoting and globbing is done) in an environment
variable, $CMDLINE. There would be no change to the default command line
handling.
I think that a standard way to match and dissect matching symbols would be a
great boon to certain command line programs (and no detriment to programs
which just want the shell to do everything). All shells should make globbing
available as a library / system call. Globbing should be standard POSIX but
with the addition of optionally returning match locations of glob / wildcard
characters.
I recommend the set CMDLINE behavior be put in the GCC compiler so that
system, execXX. and spawnXX all set the CMDLINE variable when calling other
programs. This would probably automatically set it for shells compiled with
GCC. Or how about putting it in '$!cmdline' to avoid any possibility of
conflict.
Ideas? Comments? Criticisms?
- Roy Ivy III