From 3c18a8f332355c218d6954c514ef8ff6026c3dcd Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 3 Jun 1999 10:52:13 +0000 Subject: use ZEPHYR_SUBS environment variable (if it exists) to determine location of subs file --- clients/zctl/zctl.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'clients') diff --git a/clients/zctl/zctl.c b/clients/zctl/zctl.c index 8e59c79..e68065a 100644 --- a/clients/zctl/zctl.c +++ b/clients/zctl/zctl.c @@ -73,25 +73,30 @@ main(argc,argv) if ((retval = ZInitLocationInfo(NULL, tty)) != ZERR_NONE) com_err(argv[0], retval, "initializing location information"); - envptr = getenv("HOME"); + envptr = getenv("ZEPHYR_SUBS"); if (envptr) strcpy(subsname,envptr); else { - if (!(pwd = getpwuid((int) getuid()))) { - fprintf(stderr,"Who are you?\n"); - exit (1); - } + envptr = getenv("HOME"); + if (envptr) + strcpy(subsname,envptr); + else { + if (!(pwd = getpwuid((int) getuid()))) { + fprintf(stderr,"Who are you?\n"); + exit (1); + } - strcpy(subsname,pwd->pw_dir); - } - strcpy(oldsubsname,subsname); - strcat(oldsubsname,OLD_SUBS); - strcat(subsname,USERS_SUBS); - if (!access(oldsubsname,F_OK) && access(subsname, F_OK)) { - /* only if old one exists and new one does not exist */ - printf("The .subscriptions file in your home directory is now being used as\n.zephyr.subs . I will rename it to .zephyr.subs for you.\n"); - if (rename(oldsubsname,subsname)) - com_err(argv[0], errno, "renaming .subscriptions"); + strcpy(subsname,pwd->pw_dir); + } + strcpy(oldsubsname,subsname); + strcat(oldsubsname,OLD_SUBS); + strcat(subsname,USERS_SUBS); + if (!access(oldsubsname,F_OK) && access(subsname, F_OK)) { + /* only if old one exists and new one does not exist */ + printf("The .subscriptions file in your home directory is now being used as\n.zephyr.subs . I will rename it to .zephyr.subs for you.\n"); + if (rename(oldsubsname,subsname)) + com_err(argv[0], errno, "renaming .subscriptions"); + } } #ifdef HAVE_SYS_UTSNAME -- cgit v1.2.3