Commit 66636e44 authored by deuce's avatar deuce
Browse files

Default to using vi is the EDITOR variable isn't set.

parent 8f68e802
......@@ -667,6 +667,20 @@ int recycle_servers(scfg_t *cfg)
return(0);
}
char *geteditor(char *edit)
{
if(getenv("EDITOR")==NULL && (getenv("VISUAL")==NULL || getenv("DISPLAY")==NULL))
strcpy(edit,"vi");
else {
if(getenv("DISPLAY")!=NULL && getenv("VISUAL")!=NULL)
strcpy(edit,getenv("VISUAL"));
else
strcpy(edit,getenv("EDITOR"));
}
return(edit);
}
int edit_cfg(scfg_t *cfg)
{
char** opt;
......@@ -674,16 +688,6 @@ int edit_cfg(scfg_t *cfg)
char cmd[1024];
char editcmd[1024];
if(getenv("EDITOR")==NULL && (getenv("VISUAL")==NULL || getenv("DISPLAY")==NULL)) {
uifc.msg("EDITOR/VISUAL environment variable(s) not found");
return(1);
}
if(getenv("DISPLAY")!=NULL && getenv("VISUAL")!=NULL)
strcpy(editcmd,getenv("VISUAL"));
else
strcpy(editcmd,getenv("EDITOR"));
if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
allocfail(sizeof(char *)*(MAX_OPTS+1));
for(i=0;i<(MAX_OPTS+1);i++)
......@@ -715,7 +719,7 @@ int edit_cfg(scfg_t *cfg)
return(0);
break;
default:
sprintf(cmd,"%s %s%s",editcmd,cfg->ctrl_dir,opt[i]);
sprintf(cmd,"%s %s%s",geteditor(editcmd),cfg->ctrl_dir,opt[i]);
do_cmd(cmd);
break;
}
......@@ -730,16 +734,6 @@ int edit_can(scfg_t *cfg)
char cmd[1024];
char editcmd[1024];
if(getenv("EDITOR")==NULL && (getenv("VISUAL")==NULL || getenv("DISPLAY")==NULL)) {
uifc.msg("EDITOR/VISUAL environment variable(s) not found");
return(1);
}
if(getenv("DISPLAY")!=NULL && getenv("VISUAL")!=NULL)
strcpy(editcmd,getenv("VISUAL"));
else
strcpy(editcmd,getenv("EDITOR"));
if((opt=(char **)MALLOC(sizeof(char *)*(MAX_OPTS+1)))==NULL)
allocfail(sizeof(char *)*(MAX_OPTS+1));
for(i=0;i<(MAX_OPTS+1);i++)
......@@ -765,7 +759,7 @@ int edit_can(scfg_t *cfg)
return(0);
break;
default:
sprintf(cmd,"%s %s%s",editcmd,cfg->text_dir,opt[i]);
sprintf(cmd,"%s %s%s",geteditor(editcmd),cfg->text_dir,opt[i]);
do_cmd(cmd);
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment