From owner-freebsd-questions@FreeBSD.ORG Thu Apr 5 16:02:29 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 27DFD106564A for ; Thu, 5 Apr 2012 16:02:29 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) by mx1.freebsd.org (Postfix) with ESMTP id DDDA08FC18 for ; Thu, 5 Apr 2012 16:02:28 +0000 (UTC) Received: from r56.edvax.de (port-92-195-101-40.dynamic.qsc.de [92.195.101.40]) by mx02.qsc.de (Postfix) with ESMTP id 0F4DF1E409; Thu, 5 Apr 2012 18:02:21 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id q35G2Lhl002083; Thu, 5 Apr 2012 18:02:21 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Thu, 5 Apr 2012 18:02:21 +0200 From: Polytropon To: Andrea Venturoli Message-Id: <20120405180221.d823cca1.freebsd@edvax.de> In-Reply-To: <4F7D4273.1010604@netfence.it> References: <4F7D4273.1010604@netfence.it> Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: Fast question abount EDITOR X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2012 16:02:29 -0000 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 , 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, ...