From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: "source" shell commands Date: Sat, 24 Mar 2007 11:24:54 -0400 Organization: Symantec Message-ID: References: <87bqii936r.fsf@baldur.tsdh.de> <85wt16btg5.fsf@lola.goethe.zz> NNTP-Posting-Host: lo.gmane.org X-Trace: sea.gmane.org 1174750718 9689 80.91.229.12 (24 Mar 2007 15:38:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 24 Mar 2007 15:38:38 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Mar 24 16:38:30 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HV8K4-0006GJ-5Y for geh-help-gnu-emacs@m.gmane.org; Sat, 24 Mar 2007 16:38:28 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HV8M5-0006Fe-N0 for geh-help-gnu-emacs@m.gmane.org; Sat, 24 Mar 2007 10:40:33 -0500 Original-Path: shelby.stanford.edu!newshub.stanford.edu!postnews.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail Original-NNTP-Posting-Date: Sat, 24 Mar 2007 10:24:54 -0500 Original-Newsgroups: gnu.emacs.help Mail-Copies-To: nobody User-Agent: MT-NewsWatcher/3.5.2 (PPC Mac OS X) X-Copies-To: never Original-Lines: 51 Original-NNTP-Posting-Host: 24.34.108.171 Original-X-Trace: sv3-eASsPRxmLV74XP5fSleQ7HGPdmuGxm6retXDWy8qWCiQhkARObPE6Jyqj5HfN1d/nTrudSDK5uU/Jmj!27vfkJdLi4FmpMS2GNcjjO3lPE5jJO83jo5okhtL8R8ZBadNM+PhX6wNRD2JwrTiwGgjFqKlHaly!Alx8pjRK5o2cSs2vJ3ZLcb0Np3xJG90rsOw3ddZbpg== Original-X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.34 Original-Xref: shelby.stanford.edu gnu.emacs.help:146557 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:42161 Archived-At: In article <85wt16btg5.fsf@lola.goethe.zz>, David Kastrup wrote: > Tassilo Horn writes: > > > Matthew Flaschen writes: > > > >> Is there an elisp function to "source" a shell file; i.e. an > >> alternative to: > >> > >> (shell-command (concat "source \"" (expand-file-name "~/.rc") "\"")) > > > > Sure. > > > > --8<---------------cut here---------------start------------->8--- > > (defun mf-source (file) > > (interactive "f") > > (shell-command (concat "source \"" file "\""))) > > --8<---------------cut here---------------end--------------->8--- > > Quoting is always good for trouble. I'd rather use > > (defun mf-source (file) > (interactive "f") > (call-process shell-file-name nil nil nil "source" file)) > > assuming that you don't care about the output. First of all, shells don't take a command line to execute as arguments. Take a look at what happens if you try it from the command line: $ bash source .bashrc source: source: No such file or directory You can do it with the -c option, but then they expect the command to be in a single argument: (call-process shell-file-name nil nil nil "-c" (format "source '%s'" file)) Second, the point of "sourcing" is to execute the commands in the current process's context. Since call-process and shell-command both execute a child process, nothing that occurs in the sourced script will have any effect on the emacs process. So even if you get the syntax right, it won't do anything different from executing the script normally. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group ***