Date: Thu, 5 Apr 2012 18:02:21 +0200 From: Polytropon <freebsd@edvax.de> To: Andrea Venturoli <ml@netfence.it> Cc: freebsd-questions@freebsd.org Subject: Re: Fast question abount EDITOR Message-ID: <20120405180221.d823cca1.freebsd@edvax.de> In-Reply-To: <4F7D4273.1010604@netfence.it> References: <4F7D4273.1010604@netfence.it>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 05 Apr 2012 08:57:55 +0200, Andrea Venturoli wrote: > Hello. > > This might be a stupid question... however... > > %setenv EDITOR emacs -nw > setenv: Too many arguments. > > %setenv EDITOR "emacs -nw" > %crontab -e > crontab: emacs -nw: No such file or directory > crontab: "emacs -nw" exited with status 1 > > > Is there a way I can easily achieve the above? > Do I really need a script which in turns call emacs -nw? According to crontab's source, the editor is invoked by an execlp() call, usr/src/usr.sbin/cron/crontab/crontab.c in line 404: execlp(editor, editor, Filename, (char *)NULL); The synopsis of this function can be found in "man 3 exec": int execlp(const char *file, const char *arg, ... /*, (char *)0 */); The manpage contains this information: The initial argument for these functions is the pathname of a file which is to be executed. and: The first argument, by convention, should point to the file name associated with the file being executed. as well as: The functions execlp(), execvp(), and execvP() will duplicate the actions of the shell in searching for an executable file if the specified file name does not contain a slash ``/'' character. For execlp() and execvp(), search path is the path specified in the environment by ``PATH'' variable. If this variable is not specified, the default path is set according to the _PATH_DEFPATH definition in <paths.h>, which is set to ``/usr/bin:/bin''. That means that $EDITOR has to contain the file name of the editor (as its location will be determined automatically). When options are added, this requirement isn't met anymore. This seems to imply that you cannot use an alias - you'd have to provide a script as you initially did assume. :-( -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120405180221.d823cca1.freebsd>