[Info-vax] Porting logical name applications to Unix
Bob Harris
nospam.News.Bob at remove.Smith-Harris.us
Sun Sep 27 19:20:34 EDT 2009
In article <4abfd7de$0$285$14726298 at news.sunsite.dk>,
Arne Vajhøj <arne at vajhoej.dk> wrote:
> Steven Schweda wrote:
> > Arne Vajhøj wrote:
> >> But you would only use a few of them and instead put the
> >> majority of the paths in a text config file.
> >
> > The same as you would use a logical name to point to a
> > config file on VMS instead of using dozens of logical names.
> > A config file can be used on any OS.
>
> It can.
>
> But many VMS apps uses lots of logicals.
>
> That is not the case for Unix apps. Ot at least I have
> never seen a Unix app using dozens of environment variables.
>
> Arne
If the environment variable was used for customization, and a lot
of things were being customized, then the application would tend
to look for a $HOME/.appnamerc (notice the trailing rc). This is
a convention, not a rule. Using a $HOME/.appnamerc file allows
individuals to customize the app the way they like.
But besides a $HOME/.appnamerc the app might look in a global
location for a system wide initialization first, such as
/etc/profile, /etc/csh.login, etc... and then go looking for
overrides in the user's home directory.
An app that only needs 1 or 2 customizations, might use an
environment variable. For example the 'less' command will look
for a LESS environment variable with command line options. The
'ls' command will look for LS_COLORS.
There are some standard environment variables such as HOME, USER,
LOGNAME, TERM, PATH, MANPATH, CDPATH, PAGER, EDITOR, TZ, DISPLAY,
etc... which lots of programs will look for and use that instead
of some default.
There is no hard and fast rule, but keep in mind that environment
variables live at the beginning of a process' stack and get passed
down to the child process' stack.
stack
-----
environ[*]
argv[*]
... there may be some library stuff here ...
main() call arguments
main() return address
main() local variables
The exact layout will depend on which platform/operating system.
Now keep in mind that UNIX started on a PDP (not sure if it was a
PDP-7, and then moved to a PDP-11, or if it was something else).
Regardless of the exact model, it had a limited amount of memory.
On a PDP-11, with a Harvard architecture, a process could have 64K
of code, 56K of data, and 8K of stack. And on PDP-11's that did
not support the Harvard architecture, it was 64K for everything
(and generally 8K was the stack).
So early UNIX programs could not go around having HUGE environment
variable lists. This establish the initial conventions, many of
which continue today, or are at least influenced by the past.
And I know there are some UNIX implementations that will put an
upper limit on the number of environment variables. So huge
environment variable lists are not encouraged if you want to build
portable code.
Thus $HOME/.appnamerc config files, or a small limited size
environment varialble for a few config prefs.
Bob Harris
More information about the Info-vax
mailing list