Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site utcsstat.UUCP Path: utzoo!utcsstat!ian From: ian@utcsstat.UUCP (Ian F. Darwin) Newsgroups: net.unix-wizards Subject: Environment variables: please use (V7 & later) Message-ID: <1404@utcsstat.UUCP> Date: Tue, 8-Nov-83 14:12:27 EST Article-I.D.: utcsstat.1404 Posted: Tue Nov 8 14:12:27 1983 Date-Received: Tue, 8-Nov-83 16:13:47 EST Organization: Univ of Toronto (UTCS) Lines: 30 A number of programs has appeared in net.sources recently which call other programs such as editors, mailers, etc., and having the names of these things burned into the code. You have to change the source to make it work with your favorite editor, mailer, or whatever. It's real easy to use environment variables to get the name of the editor, mailer or paginator which joe foo user wants to use. It adds all of four lines to the code. To wit (basically grepped from working code): #define DEFEDITOR "/bin/ed" #define ENVEDITOR "EDITOR" char *p, editor[BUFSIZ], *getenv(); ... ... strcpy(editor, (p=getenv(ENVEDITOR))==NULL?DEFEDITOR:p); That's all there is to it. You can then say sprintf(cmdline,"%s %s",editor,filename); if (system(cmdline) != 0){ fprintf(stderr,"?edit failed?"); other error action (exit, return...) } That's the tutorial. The plea? Please use environment variables *whenever* you want the name of an EDITOR, PAGER, MAILER or similar class of program. It makes life much easier for those of us who just explained to joe t. user that setting EDITOR works in readnews, now we don't have to explain why it *doesn't* work in your code. Thanks.