NAME
editor - execute the user’s favorite editor

SYNOPSIS
int editor (file,message);
char *file,*message;

DESCRIPTION
Editor will execute the editor preferred by the user, to edit the
file whose name is file. The string message will be printed to
tell the user what he is editing.

This routine contains all the special knowledge needed to execute
the editors known to the system; if the user wants to use some
other editor, it will be done but with no special assistance from
this routine.

There is assumed to be an environment parameter called EDITOR,
whose value is the name of the user’s favorite editor (e.g. ex,
emacs). If the EDITOR parameter is missing from the environment,
some default editor will be used.

The runp(3) routine is used to execute the editor; it uses the PATH
environment parameter to find the editor. In general, if the
editor can be found by the shell, it should be found by editor.

Editor returns the return code of the editor upon normal
completion, or -1 if the editor if interrupted or cannot be
executed.

This routine is useful for any program which allows the user to
edit a text file.

ENVIRONMENT
EDITOR
is assumed to be the name of the user’s favorite editor.
Typical values include "ex", "vi", "emacs", and "ed", but any
other editor is also acceptable; it will be executed with a
single parameter which is the name of the file to be edited.
The value of EDITOR may be an absolute name, if desired.

PATH
is assumed to be the searchlist for executable programs.

SEE ALSO
ed(1), ex(1), runp(3)

DIAGNOSTICS
Returns -1 if the editor cannot be successfully executed, 0
normally, >0 if the editor itself discovers some error condition.

BUGS
The default editor is emacs.

If message contains a newline, it may not be completely meaningful
when using some screen-oriented editors.