name=value or -n value

donn at sdchema.UUCP donn at sdchema.UUCP
Sun Mar 25 18:14:57 AEST 1984


What has not been mentioned is that Unix DOES support a standard
name=value syntax for passing information to programs: namely, the
Bourne Shell syntax for assigning to environment variables.  With the
proper option decoder one could arrange to get either 'name=value' or
'-n value' options, and without ambiguity -- 'name=value' appears to
the left of the command, '-n value' to the right.  You might imagine
being able to issue a compile two ways:

	$ cc -O -DDEBUG -s -o foo foo.c

or

	$ optimizer=on define=DEBUG strip=on output=foo cc foo.c

In fact there would be several nice side effects to using environment
variables for setting options.  For example, environment variables can
be sticky:

	$ mt -f /dev/rmt0 fsf 1
	$ tar xvf /dev/rmt0 file
	$ mt -f /dev/rmt0 fsf 1

could instead be

	$ tape=/dev/rmt0
	$ export tape
	$ mt fsf 1
	$ tar xv file
	$ mt rew

Another advantage is that environment variables are inherited -- if
you are running a program which calls other programs, you can pass
options to these subsidiary programs with environment variables.
In the case of the C compile above, the compiler wouldn't have to
make any special arrangements to pass 'strip=on' to the loader, unlike
the current way things are done where an argument list must be
re-formulated for each subprogram.

And notice that the operating system and libraries and shell need not
change to implement this scheme...  Alas, some sort of consistent
option parsing must be enforced.

I doubt this will satisfy either faction,

Donn Seeley    UCSD Chemistry Dept.       ucbvax!sdcsvax!sdchema!donn
32 52' 30"N 117 14' 25"W  (619) 452-4016  sdcsvax!sdchema!donn at nosc.ARPA



More information about the Comp.unix mailing list